首页 文章

Azure AD openid连接不包括token_type作为响应

提问于
浏览
2

我正在尝试从旧的Azure AD OpenId Connect转换为使用新的Azure AD v2.0 endpoints ,如下所示:https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oidc

当我尝试通过v2.0令牌 endpoints 请求令牌时:https://login.microsoftonline.com/common/oauth2/v2.0/token我收到的响应只包含'token_id'字段,而不是'token_type'或任何其他字段 . 我用来解析响应的库是用于openid和auth2的nimbus.com库 . OIDCTokenReponseParser抛出异常,因为响应中缺少'token_type' .

我查看了OpenID Connect协议规范,它说对令牌 endpoints 的请求需要'token_type',因此看起来 endpoints 的响应无效 .

有没有人遇到过这个问题,如果有的话,你是怎么处理它的?

UPDATE 3/2/2018

我的流程适用于旧的终点 . 我在这里重定向用户:

https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=&redirect_uri=&scope=openid+profile+email&state=

用户登录,并将其重定向到我的应用程序,并通过查询参数提供代码 .

我转过身来提出这个要求:

https://login.microsoftonline.com/common/oauth2/token?code=&grant_type=authorization_code&client_secret=

我得到的反应看起来像这样 .

{
    "token_type": "Bearer",
    "expires_in": "3599",
    "ext_expires_in": "0",
    "expires_on": "1520018953",
    "access_token": "{token}",
    "refresh_token": "{token}",
    "id_token": "{token}"
}

我尝试以同样的方式处理v2.0版本 . 我将用户重定向到:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=&redirect_uri=&scope=openid+profile+email&state=

在他们登录后,他们会被重定向回我的应用程序,并以“代码”作为查询参数 .

然后我发送此请求:

https://login.microsoftonline.com/common/oauth2/v2.0/token?code=&grant_type=authorization_code&client_secret=&redirect_uri=&client_id=

但这是我得到的回应:

{
"id_token":"{token}"
}

1 回答

  • 2

    您请求的范围只能满足ID令牌的内容 . 在您的身份验证请求中,尝试包含一个范围,表明您需要访问令牌(例如https://graph.microsoft.com/User.Read),并且响应将具有预期的 token_typeaccess_token .

相关问题