Debian Codegraph @

docs/socialaccount/provider_configuration.rst

raw
1 Provider Configuration
2 ======================
3
4 Providers typically require various configuration parameters before your users
5 can authenticate with them. For example, for a regular OAuth provider you first
6 need to setup an OAuth app over on the provider developer portal. Then, you need
7 to configure the resulting client ID and client secret in your application.
8
9 Even though providers with other protocols may use different terminology, the
10 overall idea remains the same. Throughout allauth the term "social app" ("app"
11 for short) refers to the unit of configuration of a provider. You provide the
12 app configuration either in your project ``settings.py``, or, by means of
13 setting up ``SocialApp`` instances via the Django admin. When picking a method,
14 consider the following:
15
16 - Using the Django admin to setup ``SocialApp`` instances effectively stores
17 secrets in your database, which has security implications.
18
19 - The ``SocialApp`` approach has (optional) support for the Django sites
20 (``django.contrib.sites``). For example, it allows you to setup multiple apps
21 for one and the same provider, and assign an app to a specific
22 site/domain. This may be of use in a multi tenant setup.
23
24 **Important**: While you can mix both methods, be aware you need to avoid
25 configuring one and the same provider both via ``settings.py`` and a
26 ``SocialApp`` instance. In that case, it is not clear what app to pick,
27 resulting in a ``MultipleObjectsReturned`` exception.
28
29 The examples presented in this documentation are all settings based. If you
30 prefer the ``SocialApp`` based approach, simply create an entry via the Django
31 admin and populate the fields exactly like listed in the example.
32
33 The ``SOCIALACCOUNT_PROVIDERS`` setting is used to configure providers and their
34 apps. Next to the secrets that are configured per app, there are also parameters
35 such as ``VERIFIED_EMAIL`` that hold for all apps. The following is an example
36 configuration::
37
38 SOCIALACCOUNT_PROVIDERS = {
39 "github": {
40 # For each provider, you can choose whether or not the
41 # email address(es) retrieved from the provider are to be
42 # interpreted as verified.
43 "VERIFIED_EMAIL": True
44 },
45 "google": {
46 # For each OAuth based provider, either add a ``SocialApp``
47 # (``socialaccount`` app) containing the required client
48 # credentials, or list them here:
49 "APPS": [
50 {
51 "client_id": "123",
52 "secret": "456",
53 "key": "",
54 "settings": {
55 # You can fine tune these settings per app:
56 "scope": [
57 "profile",
58 "email",
59 ],
60 "auth_params": {
61 "access_type": "online",
62 },
63 },
64 },
65 ],
66 # The following provider-specific settings will be used for all apps:
67 "SCOPE": [
68 "profile",
69 "email",
70 ],
71 "AUTH_PARAMS": {
72 "access_type": "online",
73 },
74 }
75 }
76
77 Note that provider-specific settings are documented `for each
78 provider separately <providers/index.html>`__.