将多个范围值传递给 Oauth 令牌端点
Passing multiple scope values to Oauth token endpoint
我正在尝试对 https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token
进行身份验证,其中 tenantId 来自 Azure AD。
只要我按以下格式只传递一个范围就可以正常工作
api://{{clientId}}/.default
如果我将多个值传递给范围参数,它会失败并出现错误 AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid.
我试过用 space、逗号和加号分隔这些值。但它永远行不通;如果我单独传递任何值,它们都有效,但我想在我的访问令牌中有多个受众,那么我该怎么做?
编辑
传递了额外的参数:
grant_type : client_credentials
client_id
client_secret
范围
因为,访问令牌只包含一个 API 的权限,为特定受众生成令牌,即我们只能指定一个 API 的范围。
此外,OAuth 流在这里是客户端凭证流,这意味着我们不能动态请求范围,只能为特定资源请求 .default
范围。
根据MS Docs,
The value passed for the scope parameter in this request should be the
resource identifier (Application ID URI) of the resource you want,
affixed with the .default suffix. For Microsoft Graph, the value is
https://graph.microsoft.com/.default
. This value informs the Microsoft
identity platform endpoint that of all the application permissions you
have configured for your app, it should issue a token for the ones
associated with the resource you want to use.
我正在尝试对 https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token
进行身份验证,其中 tenantId 来自 Azure AD。
只要我按以下格式只传递一个范围就可以正常工作
api://{{clientId}}/.default
如果我将多个值传递给范围参数,它会失败并出现错误 AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid.
我试过用 space、逗号和加号分隔这些值。但它永远行不通;如果我单独传递任何值,它们都有效,但我想在我的访问令牌中有多个受众,那么我该怎么做?
编辑
传递了额外的参数:
grant_type : client_credentials
client_id
client_secret
范围
因为,访问令牌只包含一个 API 的权限,为特定受众生成令牌,即我们只能指定一个 API 的范围。
此外,OAuth 流在这里是客户端凭证流,这意味着我们不能动态请求范围,只能为特定资源请求 .default
范围。
根据MS Docs,
The value passed for the scope parameter in this request should be the resource identifier (Application ID URI) of the resource you want, affixed with the .default suffix. For Microsoft Graph, the value is
https://graph.microsoft.com/.default
. This value informs the Microsoft identity platform endpoint that of all the application permissions you have configured for your app, it should issue a token for the ones associated with the resource you want to use.