Contrib¶
GitHub¶
Pre-configured remote application for enabling sign in/up with GitHub.
Usage:
Ensure you have
github3.py
package installed:cdvirtualenv src/invenio-oauthclient pip install -e .[github]
Edit your configuration and add:
from invenio_oauthclient.contrib import github OAUTHCLIENT_REMOTE_APPS = dict( github=github.REMOTE_APP, ) GITHUB_APP_CREDENTIALS = dict( consumer_key='changeme', consumer_secret='changeme', )
Go to GitHub and register a new application: https://github.com/settings/applications/new. When registering the application ensure that the Authorization callback URL points to:
CFG_SITE_SECURE_URL/oauth/authorized/github/
(e.g.http://localhost:4000/oauth/authorized/github/
for development).Grab the Client ID and Client Secret after registering the application and add them to your instance configuration (
invenio.cfg
):GITHUB_APP_CREDENTIALS = dict( consumer_key='<CLIENT ID>', consumer_secret='<CLIENT SECRET>', )
Now go to
CFG_SITE_SECURE_URL/oauth/login/github/
(e.g. http://localhost:4000/oauth/login/github/)Also, you should see GitHub listed under Linked accounts: http://localhost:4000//account/settings/linkedaccounts/
By default the GitHub module will try first look if a link already exists between a GitHub account and a user. If no link is found, the module tries to retrieve the user email address from GitHub to match it with a local user. If this fails, the user is asked to provide an email address to sign-up.
In templates you can add a sign in/up link:
<a href='{{url_for('invenio_oauthclient.login', remote_app='github')}}'>
Sign in with GitHub
</a>
ORCID¶
Pre-configured remote application for enabling sign in/up with ORCID.
Usage:
Edit your configuration and add:
from invenio_oauthclient.contrib import orcid OAUTHCLIENT_REMOTE_APPS = dict( orcid=orcid.REMOTE_APP, ) ORCID_APP_CREDENTIALS = dict( consumer_key="changeme", consumer_secret="changeme", )
Note, if you want to use the ORCID Member API, use
orcid.REMOTE_MEMBER_APP
instead oforcid.REMOTE_APP
.In case you want use sandbox: To use the ORCID Public API sandbox, use
orcid.REMOTE_SANDBOX_APP
instead oforcid.REMOTE_APP
. To use the ORCID Member API sandbox, useorcid.REMOTE_SANDBOX_MEMBER_APP
.
Register a new application with ORCID. When registering the application ensure that the Redirect URI points to:
CFG_SITE_URL/oauth/authorized/orcid/
(note, ORCID does not allow localhost to be used, thus testing on development machines is somewhat complicated by this).Grab the Client ID and Client Secret after registering the application and add them to your instance configuration (
invenio.cfg
):ORCID_APP_CREDENTIALS = dict( consumer_key="<CLIENT ID>", consumer_secret="<CLIENT SECRET>", )
Now go to
CFG_SITE_URL/oauth/login/orcid/
(e.g. http://localhost:4000/oauth/login/orcid/)Also, you should see ORCID listed under Linked accounts: http://localhost:4000/account/settings/linkedaccounts/
By default the ORCID module will try first look if a link already exists between a ORCID account and a user. If no link is found, the user is asked to provide an email address to sign-up.
In templates you can add a sign in/up link:
<a href="{{url_for('invenio_oauthclient.login', remote_app='orcid')}}">
Sign in with ORCID
</a>
CERN¶
Pre-configured remote application for enabling sign in/up with CERN.
Usage:
Edit your configuration and add:
import copy from invenio_oauthclient.contrib import cern CERN_REMOTE_APP = copy.deepcopy(cern.REMOTE_APP) CERN_REMOTE_APP["params"].update(dict(request_token_params={ "resource": "changeme.cern.ch", # replace with your server "scope": "Name Email Bio Groups", })) OAUTHCLIENT_REMOTE_APPS = dict( cern=CERN_REMOTE_APP, ) CERN_APP_CREDENTIALS = dict( consumer_key="changeme", consumer_secret="changeme", )
Note, if you want to use the CERN sandbox, usecern.REMOTE_SANDBOX_APP
instead ofcern.REMOTE_APP
.
Register a new application with CERN. When registering the application ensure that the Redirect URI points to:
http://localhost:5000/oauth/authorized/cern/
(note, CERN does not allow localhost to be used, thus testing on development machines is somewhat complicated by this).Grab the Client ID and Client Secret after registering the application and add them to your instance configuration (
invenio.cfg
):CERN_APP_CREDENTIALS = dict( consumer_key="<CLIENT ID>", consumer_secret="<CLIENT SECRET>", )
Now login using CERN OAuth: http://localhost:5000/oauth/login/cern/.
Also, you should see CERN listed under Linked accounts: http://localhost:5000/account/settings/linkedaccounts/
By default the CERN module will try first look if a link already exists between a CERN account and a user. If no link is found, the user is asked to provide an email address to sign-up.
In templates you can add a sign in/up link:
<a href="{{ url_for("invenio_oauthclient.login", remote_app="cern") }}">
Sign in with CERN
</a>