apps.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from django.apps import AppConfig
  2. from social_core.backends.facebook import FacebookOAuth2
  3. from social_core.backends.github import GithubOAuth2
  4. from social_core.backends.google import GoogleOAuth2
  5. from social_core.backends.twitter import TwitterOAuth
  6. from .providers import providers
  7. class MisagoSocialAuthConfig(AppConfig):
  8. name = "misago.socialauth"
  9. label = "misago_socialauth"
  10. verbose_name = "Misago Social Auth"
  11. def ready(self):
  12. # Register default providers
  13. from .admin.forms import FacebookForm, GitHubForm, GoogleForm, TwitterForm
  14. providers.add(
  15. provider="facebook",
  16. name="Facebook",
  17. auth_backend=FacebookOAuth2,
  18. settings={"scope": ["email"]},
  19. admin_form=FacebookForm,
  20. admin_template="misago/admin/socialauth/form.html",
  21. )
  22. providers.add(
  23. provider="github",
  24. name="GitHub",
  25. auth_backend=GithubOAuth2,
  26. settings={"scope": ["read:user", "user:email"]},
  27. admin_form=GitHubForm,
  28. admin_template="misago/admin/socialauth/form.html",
  29. )
  30. providers.add(
  31. provider="google-oauth2",
  32. name="Google",
  33. auth_backend=GoogleOAuth2,
  34. admin_form=GoogleForm,
  35. admin_template="misago/admin/socialauth/form.html",
  36. )
  37. providers.add(
  38. provider="twitter",
  39. name="Twitter",
  40. auth_backend=TwitterOAuth,
  41. admin_form=TwitterForm,
  42. admin_template="misago/admin/socialauth/form.html",
  43. )