Add the requests-oauthlib dependency to your requirements.txt
and run pip install -r requirements.txt
flask requests-oauthlib
client_id = '[YOUR_CLIENT_ID]' client_secret = '[YOUR_CLIENT_SECRET]' redirect_uri = '[YOUR_REDIRECT_URI]' authorization_base_url = 'https://api.id.me/oauth/authorize' token_url = 'https://api.id.me/oauth/token' attributes_url = 'https://api.id.me/api/public/v3/attributes.json' scope = kyc
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
redirect(authorization_url)
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)}
Use the access token to call ID.me'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.