我正在尝试使用(https://graph.microsoft.com/v1.0/me/calendarView)之后的node.js上的Microsoft Graph API this permissions guide访问日历事件,但我收到错误响应:
{
"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again.",
"innerError": {
"request-id": "7c2...",
"date": "2016-07-13T21:19:11"
}
}
使用以下方式进行了调用:
request({url : 'https://graph.microsoft.com/v1.0/me/calendarview', qs : queryParams, 'auth': {'bearer': token}}, function (error, response, body) {
...
});
请求有一个有效的令牌和对... / me / via
的调用request({url : 'https://graph.microsoft.com/v1.0/me/', 'auth': {'bearer': token}}, function (error, response, body) {
...
});
返回:
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id":"<valid_id>",
"businessPhones":[],
"displayName":"<valid_name>",
"givenName":"<valid_name>",
"jobTitle":"<valid_title>",
"mail":"<valid_email>",
"mobilePhone":"<valid_cell>",
"officeLocation":null,
"preferredLanguage":"en-US",
"surname":"<valid_name>",
"userPrincipalName":"<valid_email>"}
所以我假设这是https://manage.windowsazure.com/设置权限的问题,我创建了两个应用程序,一个用于节点服务器,另一个用于Web客户端应用程序。我使用护照进行身份验证以及Web客户端应用程序的客户端ID和密码。
var AzureOAuthStrategy = require('passport-azure-oauth').Strategy;
passport.use(new AzureOAuthStrategy({
clientId: config.live.clientID,
clientSecret: config.live.clientSecret,
tenantId: config.live.tenant,
resource: 'https://graph.microsoft.com/',
redirectURL: config.live.callbackURL
},
function(accessToken, refreshToken, profile, done) {
以下是我为其他应用程序设置的权限#34;在节点应用程序:
以下是我为其他应用程序设置的权限#34;在 Web客户端应用程序:
我不是100%了解azure管理门户中设置的权限与特定端点访问之间的关系。我已阅读API scope article,但该文章中的讨论对我的需求来说有点过于概念化。
最终,我正在尝试访问并向租户ID中的所有可预留资源写入事件。
答案 0 :(得分:1)
我能够通过删除然后通过https://manage.windowsazure.com/重新生成应用程序然后更新客户端ID和密码来解决问题。事实上,我能够从应用程序列表中删除本机客户端(节点)应用程序,并仍然可以使调用工作。
虽然我没有使用Fei Xue提供的参考https://jwt.io/,但我认为将来调试azure到API权限是非常宝贵的。