A django-allauth provider for the Orfium.com music platform.
pip install orfium-oauth-provider==0.1.6
This packages is a plugin on top of the django-allauth app that provides the Orfium music platform as an OAuth provider. Package is compatible with Django >= 1.7 (including Django 2).
Add django-allauth
and orfium-oauth-provider
as requirements to your project and install them.
Add the following apps to your INSTALLED_APPS
'django.contrib.auth'
,'django.contrib.sites'
,'allauth'
,'allauth.account'
,'allauth.socialaccount'
,In case you use DRF, add 'rest_framework.authtoken'
,'orfium_oauth_provider'
,Make sure the following context processor is included in the TEMPLATES
setting:
'django.template.context_processors.request'
Add 'allauth.account.auth_backends.AuthenticationBackend'
to the AUTHENTICATION_BACKENDS
setting.
Specify the social account adapter (Allows connecting the orfium user account to your apps local users based on their usernames):
SOCIALACCOUNT_ADAPTER = 'orfium_oauth_provider.adapters.ConnectExistingUsersSocialAccountAdapter'
Set SITE_ID = 1
in your settings
Use /accounts/orfium_oauth2/login/?process=login
as the login link to automatically redirect users to Orfium,
or optionally add the following to your MIDDLEWARE
setting if you want all pages to be protected:
orfium_oauth_provider.middlewares.AuthRequiredMiddleware
If you use the middleware, you can specify which paths should be ignored by using the AUTH_REQUIRED_IGNORE_PATHS
setting:
AUTH_REQUIRED_IGNORE_PATHS = [
'/accounts/', # all URLs that start with /accounts/
'/admin/', # all URLs that start with /admin/
]
Add the following to your urls:
url(r'^accounts/', include('allauth.urls'))
Migrate:
python manage.py migrate
Register your application at https://api.orfium.com/oauth/applications/ and make sure you specify the client type as Public
and the authorization grant type as Authorization code
.
You may use the API_ORFIUM_ENDPOINT
setting if you want your application to use an alternative endpoint such as https://api.dev.orfium.com
.
By default the endpoint is set to https://api.orfium.com
. Use <YOUR_APP_BASE_URL>/accounts/orfium_oauth2/login/callback/
as the redirect URI.
Update your sites info under Sites
in the admin and create a new social application for the Orfium provider,
using the App ID and Token you got from the previous step.