Install the ITSME® PyPi package to your project to get started.
$ pip install itsme
Import the ITSME® project into your code.
Initialize the ITSME® client with your configuration. Replace
my_private_jwks.json with your actual key file by reading the content or adding it as a string.
jwks = '' with open('jwks_private.json','r') as jwks_file: jwks = jwks_file.read() client_id = 'my_client_id' redirect_url = 'https://i/redirect' private_jwk_set = jwks settings = itsme.ItsmeSettings(client_id, redirect_url, private_jwk_set) client = itsme.Client(settings)
config = itsme.UrlConfiguration(['profile', 'email'], 'my_service_code', '') itsme_auth_url = client.get_authentication_url(config)
Once generated, you can use this to redirect to itsme. After succesful authentication by the user, ITSME® will redirect to your configured backend url with an authorization code.
user = client.get_user_details('authorization_code')
The returned user contains all the information requested by you. Make sure to only use the
sub identifier to link or reference an ITSME® user from your data as all other parameters can be subject to change.
As an extra means of flexibility, allow the update of the
sub identifier for existing users as well. Due to security reasons, it can happen existing users are migrated to a new identifier, so for logged in users allow to update their ITSME® linked account.