social-auth.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Vue from 'vue';
  2. import axios from "axios";
  3. import UniversalSocialAuth from "universal-social-auth";
  4. const defaultOptions = {
  5. redirectUri: window.location.origin,
  6. oauthType: "2.0",
  7. responseType: "code",
  8. optionalUrlParams: ["display", "scope"],
  9. usePopup: true,
  10. display: "popup",
  11. state: true,
  12. popupOptions: { width: 500, height: 500 },
  13. }
  14. const options = {
  15. providers: {
  16. vk: {
  17. name: "vk",
  18. clientId: '6199950',
  19. authorizationEndpoint: "https://oauth.vk.com/authorize",
  20. scope: 'email',
  21. ...defaultOptions
  22. },
  23. ok: {
  24. name: "ok",
  25. clientId: '1255143936',
  26. authorizationEndpoint: "https://connect.ok.ru/oauth/authorize",
  27. scope: 'VALUABLE_ACCESS,GET_EMAIL',
  28. ...defaultOptions
  29. },
  30. fb: {
  31. name: "fb",
  32. clientId: '421123926237121',
  33. authorizationEndpoint: "https://www.facebook.com/v12.0/dialog/oauth",
  34. scope: 'public_profile,email',
  35. ...defaultOptions
  36. },
  37. }
  38. };
  39. const oauth = new UniversalSocialAuth(axios, options);
  40. Vue.prototype.$oauth = oauth;