[FIXED] how to get id_token in Python Flask OpenID?


I have successfully implemented Keycloak OpenID + Python (v3.6) Flask integration using Flask-oidc.

I use below code to get user info,access_token and refresh_token

oidc = OpenIDConnect(app)
info = oidc.user_getinfo(['preferred_username', 'email', 'sub', 'given_name', 'iss'])
access_token = oidc.get_access_token()
refresh_token = oidc.get_refresh_token()

And got the results as well. But for a reason i need id_token as well. I tried,


(which is already deprecated), but it gave decoded result not encoded token.

Anybody know how to get id_token from flask-oidc ?


I found a solution,

from oauth2client.client import OAuth2Credentials
id_token_jwt = OAuth2Credentials.from_json(oidc.credentials_store[info.get('sub')]).id_token_jwt

Answered By – James Arems

Answer Checked By – Cary Denson (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published