Debian Codegraph @

docs/socialaccount/templates.rst

raw
1 Template Tags
2 =============
3
4 Use the ``provider_login_url`` tag to generate provider specific login URLs::
5
6 {% load socialaccount %}
7
8 <a href="{% provider_login_url "openid" openid="https://www.google.com/accounts/o8/id" next="/success/url/" %}">Google</a>
9 <a href="{% provider_login_url "twitter" %}">Twitter</a>
10
11 Here, you can pass along an optional ``process`` parameter that
12 indicates how to process the social login. You can choose between
13 ``login`` and ``connect``::
14
15 <a href="{% provider_login_url "twitter" process="connect" %}">Connect a Twitter account</a>
16
17 Furthermore, you can pass along an ``action`` parameter with value
18 ``reauthenticate`` to indicate that you want the user to be re-prompted
19 for authentication even if they already signed in before. For now, this
20 is supported by Facebook, Google, Twitter, and Discord only.
21
22 For Javascript based logins (e.g. when you enable the Facebook JS
23 SDK), you will need to make sure that the required Javascript is
24 loaded. The following tag loads all scripts for the enabled
25 providers::
26
27 {% providers_media_js %}
28
29 For easy access to the social accounts for a user use::
30
31 {% get_social_accounts user as accounts %}
32
33 Then::
34
35 {{accounts.twitter}} -- a list of connected Twitter accounts
36 {{accounts.twitter.0}} -- the first Twitter account
37 {% if accounts %} -- if there is at least one social account
38
39
40 Finally, social authentication providers configured for the current site
41 can be retrieved via::
42
43 {% get_providers as socialaccount_providers %}
44
45 Which will populate the ``socialaccount_providers`` variable in the
46 template context with a list of configured social authentication
47 providers. This supersedes the context processor used in version 0.21 and
48 below.