Python Web App
Choose API Version:
V3 V2

View the full sample project on Github

Step 1. Add dependencies

Add the requests-oauthlib dependency to your requirements.txt and run pip install -r requirements.txt


Step 2. Configure your client settings and secrets

client_id              = '[YOUR_CLIENT_ID]'
client_secret          = '[YOUR_CLIENT_SECRET]'
redirect_uri           = '[YOUR_REDIRECT_URI]'
authorization_base_url = ''
token_url              = ''
attributes_url         = ''
scope                  = kyc

Step 3. Redirect the user to's OAuth 2.0 server

Generate the authorization endpoint URL

idme = OAuth2Session(client_id, redirect_uri=redirect_uri, scope=scope)
authorization_url = idme.authorization_url(authorization_base_url)

Redirect the user to the authorization_url


Step 4. Exchange the code for an access token

Use the fetch_token method to exchange the authorization code for an access token

token = idme.fetch_token(token_url, client_secret=client_secret, authorization_response=request.url)}

Step 5. Call's API

Use the access token to call's API and retrieve the user's attributes

idme = OAuth2Session(client_id, token=token)
payload = idme.get('attributes_url').json()

You can check the user's attributes via payload['attributes'] and payload['status'] arrays.