据此: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."}}}
当我在应用程序中执行某些操作时,令牌被接受,因此我不相信它的格式错误。
我一直遇到这个问题。我正在使用以下代码来获取本机应用程序的承载令牌:
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] 删除。
我来说两句