我正在使用Python ADAL库使用Azure Active Directory对用户进行身份验证。我成功收到访问令牌后身份验证。现在,我想验证访问令牌的有效性。在这种情况下,我需要ID_TOKEN。我如何获得?
import adal
auth_context = adal.AuthenticationContext("https://login.microsoftonline.com/{{tenant_id}}")
token_response = auth_context.acquire_token_with_username_password("https://management.core.windows.net/", username, password, client_id)
在令牌响应中,我得到了access_token和refresh_token,但是没有收到id_token。遵循类似的问题,How to verify JWT id_token produced by MS Azure AD?我使用代码验证访问令牌,但我需要ID_TOKEN。
关于获得此功能的任何想法都会很棒。
不需要获取ID_TOKEN
,请尝试如下代码。
import adal
import jwt
auth_context = adal.AuthenticationContext("https://login.microsoftonline.com/{{tenant_id}}")
token_response = auth_context.acquire_token_with_username_password("https://management.core.windows.net/", username, password, client_id)
token_header = jwt.get_unverified_header(token_response['accessToken'])