Created
February 14, 2020 15:56
-
-
Save XaviTorello/e7793b1c6f68fe60a0036d581d3cd361 to your computer and use it in GitHub Desktop.
AppleId custom new backends with different settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: an_app/backends.py | |
from social_core.backends.apple import AppleIdAuth | |
""" | |
It provides 2 backends that extends the AppleID base auth | |
Useful to be able to define different configs depending on the singin scenario | |
The name will be used to fetch concrete settings and link it at the `provider` field (or the `/jwt-pair/$name` URI) | |
""" | |
class AppleIdAppAuth(AppleIdAuth): | |
""" | |
Default AppleID backend for app logins. | |
Will load SOCIAL_AUTH_APPLE_ID_FROM_APP_* settings and expose it as provider = "apple-id-from-app" (or your URL /jwt-pair/apple-id-from-app) | |
""" | |
name = "apple-id-from-app" | |
class AppleIdWebAuth(AppleIdAuth): | |
""" | |
Default AppleID backend for app logins. | |
Is the same than AppleIdAuth, but helps to ensure that provider name does not change. | |
""" | |
name = "apple-id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#file: settings/__init__.py # or your backends loader | |
... | |
AUTHENTICATION_BACKENDS = [ | |
... | |
# 'social_core.backends.apple.AppleIdAuth', | |
'users.backends.AppleIdAppAuth', | |
'users.backends.AppleIdWebAuth', | |
... | |
] | |
SOCIAL_AUTH_APPLE_ID = 'com.client.base' | |
SOCIAL_AUTH_APPLE_KEY = '...' | |
... | |
# FROM APP settings // | |
SOCIAL_AUTH_APPLE_ID_FROM_APP_CLIENT = 'com.client.app' | |
SOCIAL_AUTH_APPLE_ID_FROM_APP_KEY = '...' | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment