Windows Azure AD 租户应用程序 oAuth 2.0 规范中的资源参数是什么 [英] What is the Resource parameter in Windows Azure AD tenant application oAuth 2.0 specification

查看:22
本文介绍了Windows Azure AD 租户应用程序 oAuth 2.0 规范中的资源参数是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用 curl 使用 oAuth 2.0 使用 Windows Azure AD 租户应用程序调用身份验证过程.但我无法弄清楚下面示例代码中的参数资源"是什么:

I'm trying to invoke an authentication process with a windows Azure AD tenant application using oAuth 2.0 by using curl. But I couldn't figure out what is the parameter "resource' in below sample code:

curl -X POST https://login.windows.net/<<YOUR--AD-TENANT-ID>>/oauth2/token  
  -F redirect_uri=http://google.com 
  -F grant_type=authorization_code 
  **-F resource=https://management.core.windows.net/ **
  -F client_id=87a544fd-... 
  -F code=AwABAAAAvPM1...8sSAA

推荐答案

Resource 参数描述了您的客户端想要代表用户访问的 WebAPI 的标识符.OAuth 中的大多数流程涉及 4 方,资源所有者(又名用户)、客户端(又名应用程序)、授权(又名身份提供者)和资源(又名 webapi).权限生成的访问令牌的受众是资源标识符.

Resource parameter depicts the identifier of the WebAPI that your client wants to access on behalf of the user. Most flows in OAuth involve 4 parties, the resource owner (aka user), the client (aka app), the authority (aka identity provider) and the resource (aka webapi). The audience of the access token that the authority generates is the resource identifier.

对于 Azure AD,您可以使用资源 WebAPI 的客户端 ID 或应用 ID URI(在 Azure 管理门户的 Azure AD 应用程序的配置选项卡中找到它们).例如,如果我希望我的客户端获得令牌以代表用户访问 Azure AD Graph API,我将请求资源https://graph.windows.net".在您的示例中,资源参数值标识 Azure 服务管理 API.

In the case of Azure AD you can either use the Client ID or the App ID URI of the resource WebAPI (Find them in the configure tab of the Azure AD application in the Azure Management portal). For instance, if I want my client to get a token to access the Azure AD Graph API on behalf of the user, I would request for a token for resource "https://graph.windows.net". In your example, the resource parameter value identifies the Azure Service Management APIs.

以下是使用 Azure AD SDK 向 WebAPI 请求令牌的客户端应用的一些代码示例 - 资源参数的不同用法:

Here are some code samples of Client Apps using Azure AD SDKs to request for tokens to WebAPIs - different usages of the resource parameter:

希望这会有所帮助.

这篇关于Windows Azure AD 租户应用程序 oAuth 2.0 规范中的资源参数是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆