How to setup Dataporten (Feide etc.) login


Make sure your AUTHENTICATION_BACKENDS setting includes "allauth.account.auth_backends.AuthenticationBackend".




You can have more authentication backends than just the _allauth_ backend, but if you only have the allauth backend, login will redirect directly to dataporten for login instead of asking users how they wish to sign in.

Setup the dataporten application

Go to, and create a new application. You probably want to create the application within an organization instead of a personal app, but for local testing, a personal app should work.

In the create new application popup

Within the application dashboard


Devilry requires that you include the following scopes:

  • Profilinfo

  • Bruker-ID

  • E-post

  • Feide-navn

Auth providers

You will most likely want to deselect: Accept all social networks, Feide gjestebrukere and Feide testbrukere. For testing purposes, Feide testbrukere may be useful, but not for production.

You will most likely want to deselect Åpne for alle i utdanningsektoren, and just select the relevant schools.

Add required data to the database

Setup your primary domain with:

$ python devilry_setup_primary_domain <your domain here>
$ ... E.g.:
$ python devilry_setup_primary_domain

Setup dataporten credentials:

$ python devilry_setup_dataporten_provider <OAuth Client credentials>
$ ... E.g.:
$ python devilry_setup_dataporten_provider xxx-xxx-xxx-xxx-xxxxx


You find the credentials for your app via (in the OAuth credentials section).

Use username instead of feide ID

By default, we use the userid_sec field from Dataporten as the “shortname” for users. This field is not very pretty, but it is unique. This means that the shortname which is used some places in the UI, looks something like this:

You can change this to just myuser (the username part) for a single userid_sec suffix with the DEVILRY_FEIDE_USERID_SEC_TO_USERNAME_SUFFIX setting. For example:


If you forget this, and set it later, the shortname of users will be updated the next time they login.