我使用V1以获得来自Microsoft REST API的令牌.(我们有Office 365租户,我曾经成功获得所有资源,但没有任何问题.
clientId =8a67......de4b6
clientSecret =J58k8....5EU=
redirectUri =http://example.com...
resourceUrl =https://graph.microsoft.com
authority = https://login.microsoftonline.com/f02633....a603/oauth2/token
Run Code Online (Sandbox Code Playgroud)
https://login.microsoftonline.com/f0263...0be3/oauth2/authorize?client_id=8a6..b6&redirect_uri=http://example.com&response_type=code&scope=mail.read
它给了我一个在JWT上结构如下的令牌.它表示无效签名但不确定是什么问题.
一旦我有了令牌,我就尝试了下面的卷曲调用
curl -i https://graph.microsoft.com/v1.0/me/messages -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Barer eyJ.[TOKEN]...UNa6nfw'
Run Code Online (Sandbox Code Playgroud)
而不是消息,我收到以下错误:
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8Cl23
Server: Microsoft-IIS/8.5
request-id: af2390b1-a9b...5ab9
client-request-id: af2390,....a615ab9
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US","Slice":"SliceA","ScaleUnit":"000","Host":"AGSFE_IN_4","ADSiteName":"WST"}}
X-Powered-By: ASP.NET
Date: Thu, 19 Jan 2017 23:55:43 GMT
Content-Length: 268
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: -2147184105",
"innerError": {
"request-id": "af2390b1-...5ab9",
"date": "2017-01-19T23:55:44"
}
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个调用 Microsoft Graph API 的简单 Azure 函数。但我无法使 access_token 工作。这是我所做的:
npm install request)和实际功能:
var request = require('request');
module.exports = function (context, req) {
var token = req.headers['x-ms-token-aad-access-token'];
var reqUrl = 'https://graph.microsoft.com/v1.0/me/';
request.get(reqUrl, {'auth': {'bearer': token}}, function (err, response, msg) {
context.res = {
body: msg
};
context.done();
});
};
Run Code Online (Sandbox Code Playgroud)在单独的浏览器窗口中测试了此功能。让我正确登录 AAD。
但是从 Graph 返回的消息是:
"{
"error": { …Run Code Online (Sandbox Code Playgroud)javascript azure node.js azure-functions microsoft-graph-api
我搜索了我发现的错误,没有找到任何匹配的问题.所以发帖问题.感谢是否有人提供了一些指导.
我的目标是在桌面客户端中访问图形API.我已经开始使用fiddler进行实验了.
请求令牌并使用Authorization标头中的令牌调用图API,获取以下错误.
https://graph.microsoft.com/v1.0/users
119
{
"error": {
"code": "Authorization_IdentityNotFound",
"message": "The identity of the calling application could not be established.",
"innerError": {
"request-id": "4c3a7bc6-e3d8-453c-adc9-5a12fec3b0ee",
"date": "2016-05-11T00:46:23"
}
}
}
Run Code Online (Sandbox Code Playgroud)