通过Rest调用查询Windows Azure Active Directory图Api

波尔·索伦森(PoulK.Sørensen)

据此:http : //msdn.microsoft.com/en-us/library/windowsazure/dn424880.aspx和此http://msdn.microsoft.com/en-us/library/windowsazure/hh974467.aspx

我应该能够发出请求

https://graph.windows.net/<my-object-guid>/tenantDetails?api-version=0.9

而且我正在使用Fiddler入门。在作曲家中进行设置:用户代理:Fiddler主机:graph.windows.net授权:Bearer eyJ0eXA ....(我的令牌,使用WAAL的一些c#获取令牌)。

这就是返回的

HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
Server: Microsoft-IIS/8.0
WWW-Authenticate: Bearer realm="<my-object-guid>", error="invalid_token", error_description="Access Token missing or malformed.", authorization_uri="https://login.windows.net/<my-object-guid>/oauth2/authorize", client_id="00000002-0000-0000-c000-000000000000"
ocp-aad-diagnostics-server-name: 11iIdMb+aPxfKyeakCML7Tenz8Kyy+G8VG19OZB/CJU=
request-id: 99d802a3-0e55-4018-b94d-a8c00ec8f171
client-request-id: 7ed93efd-86c5-4900-ac1f-747a51fe1d8a
x-ms-dirapi-data-contract-version: 0.9
X-Content-Type-Options: nosniff
DataServiceVersion: 3.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ARR/3.0
X-Powered-By: ASP.NET
Date: Tue, 14 Jan 2014 00:13:27 GMT
Content-Length: 129

{"odata.error":{"code":"Authentication_MissingOrMalformed","message":{"lang":"en","value":"Access Token missing or malformed."}}}

当我在应用程序中做一些事情时,令牌就被接受了,所以我不相信它的格式错误。

第45章

我一直遇到这个问题。我正在使用以下代码来获取本机应用程序的承载令牌:

        var authContext = new AuthenticationContext("AUTHORITY");
        string token;
        try
        {
            var authresult = authContext.AcquireToken("MYAPP_ID","MYAPP_CLIENTID","MYAPP_REDIRECTURI");
            token = authresult.AccessToken;
        }

使用该令牌可以在我自己的应用中授权操作,但在尝试使用与Graph API相同的令牌作为授权时,我会得到与OP相同的错误。

我要做的是获得一个专门用于Graph API的新令牌-我使用了与上面相同的代码,但我使用"https://graph.windows.net"而不是"MYAPP_ID"因此,很明显,以下代码为我提供了Graph API的正确OAuth令牌:

        var authContext = new AuthenticationContext("AUTHORITY");
        string token;
        try
        {
            var authresult = authContext.AcquireToken("https://graph.windows.net","MYAPP_CLIENTID","MYAPP_REDIRECTURI");
            token = authresult.AccessToken;
        }

只要确保您在Azure中注册的应用程序具有访问Azure域目录的必要权限即可。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Azure服务查询Azure Active Directory

使用Azure Active Directory保护外部API的调用我的API

如何将Web Api访问配置为Azure Active Directory图API

通过JavaScript调用的Azure Active Directory保护WebApi

是否可以从Azure SQL查询Active Directory

401错误-使用AZURE Active Directory(JavaScript客户端)保护调用REST API

管理Windows Azure Active Directory用户的工具

将Windows Azure Pack与Active Directory集成

Windows Azure Active Directory自动密码更改

使用 Azure Active Directory 时 Azure Devops REST API 身份验证失败

Azure Active Directory角色

Azure Active Directory注销

使用Microsoft Graph API(不是Azure AD API)在Azure Active Directory中查询自定义属性

使用Azure Service Management REST API作为已注册的Active Directory应用程序

Azure Active Directory B2C是否具有REST Api?

使用Azure Active Directory + REST API的MVC5应用-验证PowerBI / O365

错误403尝试通过Active Directory访问Azure Databricks API时未授权用户

通过SPA + Web API中的MSAL检查Azure Active Directory组成员身份

角单页应用程序通过Azure Active Directory访问多个受保护的Web API

是否可以从本地 SQL Server 查询 Azure Active Directory?

异步调用时,Azure KeyVault Active Directory AcquireTokenAsync超时

使用Azure Active Directory保护REST WebApi2服务

远程工作人员通过Azure Active Directory登录

Windows Azure Active Directory同步与本地AD(子域)

编写Windows Azure Active Directory的注册页面

使用 Windows 身份验证登录 Azure Active Directory

与 Azure Active Directory 之间的迁移

如何访问Azure Active Directory?

获取Azure Active Directory令牌