访问被拒绝。检查凭据并重试

Access is denied. Check credentials and try again

我正在尝试按照此权限指南在 node.js 上使用 Microsoft Graph API (https://graph.microsoft.com/v1.0/me/calendarView) 访问日历事件,但我收到错误响应:

{

 "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) {

  ...

});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>"}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) {

调用是使用 :

{

 "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) {

  ...

});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>"}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) {

请求有一个有效的令牌,并且通过

调用 .../me/

{

 "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) {

  ...

});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>"}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) {

返回:

{

 "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) {

  ...

});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>"}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) {

所以我假设这是在 https://manage.windowsazure.com/ 上设置权限的问题,我在其中创建了两个应用程序,一个用于节点服务器,一个用于 Web 客户端应用程序。我正在使用护照进行身份验证,并使用 Web 客户端应用程序的客户端 ID 和密码。

{

 "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) {

  ...

});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>"}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) {

这是我在节点应用程序上为"其他应用程序的权限"设置的:

  • Windows Azure 活动目录:
    • 委托权限
      • 阅读所有用户的完整个人资料
      • 登录并阅读用户资料
  • 微软图表:
    • 委托权限
      • 拥有对用户日历的完全访问权限
      • 阅读用户日历
  • (见下文)
    • 委托权限
      • 使用权

这是我在 Web 客户端应用程序上为"其他应用程序的权限"设置的内容:

  • 微软图形:
    • 申请权限
      • 在所有邮箱中读取和写入日历
      • 阅读所有邮箱中的日历
    • 委托权限
      • 登录用户
      • 读取用户联系人
      • 拥有对用户日历的完全访问权限
      • 阅读用户日历
      • 登录并阅读用户资料
  • Office Exchange 360?? 在线版:
    • 申请权限
      • 在所有邮箱中读取和写入日历
      • 阅读所有邮箱中的日历
    • 委托权限
      • 读取用户和共享日历
      • 读写用户和共享日历
      • 阅读所有用户的基本资料
      • 阅读用户资料
      • 读取用户联系人
      • 阅读用户日历
  • Windows Azure 活动目录
    • 申请权限:无
    • 委托权限
      • 登录并阅读用户资料

我不是 100% 了解 Azure 管理门户中设置的权限与特定端点访问之间的关系。我已阅读 API 范围文章,但该文章中的讨论对于我的需求来说有点过于概念化。

最终,我试图访问租户 ID 内的所有可预留资源并将事件写入事件。


我能够通过删除然后通过 https://manage.windowsazure.com/ 重新生成应用程序然后更新客户端 ID 和密码来解决问题。事实上,我能够从应用程序列表中删除本机客户端(节点)应用程序,并且仍然可以进行调用。

虽然我没有使用飞雪提供的参考 https://jwt.io/,但我认为它对于将来调试 azure to API 权限将非常有用。


相关推荐

  • Spring部署设置openshift

    Springdeploymentsettingsopenshift我有一个问题让我抓狂了三天。我根据OpenShift帐户上的教程部署了spring-eap6-quickstart代码。我已配置调试选项,并且已将Eclipse工作区与OpehShift服务器同步-服务器上的一切工作正常,但在Eclipse中出现无法消除的错误。我有这个错误:cvc-complex-type.2.4.a:Invali…
    2025-04-161
  • 检查Java中正则表达式中模式的第n次出现

    CheckfornthoccurrenceofpatterninregularexpressioninJava本问题已经有最佳答案,请猛点这里访问。我想使用Java正则表达式检查输入字符串中特定模式的第n次出现。你能建议怎么做吗?这应该可以工作:MatchResultfindNthOccurance(intn,Patternp,CharSequencesrc){Matcherm=p.matcher…
    2025-04-161
  • 如何让 JTable 停留在已编辑的单元格上

    HowtohaveJTablestayingontheeditedcell如果有人编辑JTable的单元格内容并按Enter,则内容会被修改并且表格选择会移动到下一行。是否可以禁止JTable在单元格编辑后转到下一行?原因是我的程序使用ListSelectionListener在单元格选择上同步了其他一些小部件,并且我不想在编辑当前单元格后选择下一行。Enter的默认绑定是名为selectNext…
    2025-04-161
  • Weblogic 12c 部署

    Weblogic12cdeploy我正在尝试将我的应用程序从Tomcat迁移到Weblogic12.2.1.3.0。我能够毫无错误地部署应用程序,但我遇到了与持久性提供程序相关的运行时错误。这是堆栈跟踪:javax.validation.ValidationException:CalltoTraversableResolver.isReachable()threwanexceptionatorg.…
    2025-04-161
  • Resteasy Content-Type 默认值

    ResteasyContent-Typedefaults我正在使用Resteasy编写一个可以返回JSON和XML的应用程序,但可以选择默认为XML。这是我的方法:@GET@Path("/content")@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})publicStringcontentListRequestXm…
    2025-04-161
  • 代码不会停止运行,在 Java 中

    thecodedoesn'tstoprunning,inJava我正在用Java解决项目Euler中的问题10,即"Thesumoftheprimesbelow10is2+3+5+7=17.Findthesumofalltheprimesbelowtwomillion."我的代码是packageprojecteuler_1;importjava.math.BigInteger;importjava…
    2025-04-161
  • Out of memory java heap space

    Outofmemoryjavaheapspace我正在尝试将大量文件从服务器发送到多个客户端。当我尝试发送大小为700mb的文件时,它显示了"OutOfMemoryjavaheapspace"错误。我正在使用Netbeans7.1.2版本。我还在属性中尝试了VMoption。但仍然发生同样的错误。我认为阅读整个文件存在一些问题。下面的代码最多可用于300mb。请给我一些建议。提前致谢publicc…
    2025-04-161
  • Log4j 记录到共享日志文件

    Log4jLoggingtoaSharedLogFile有没有办法将log4j日志记录事件写入也被其他应用程序写入的日志文件。其他应用程序可以是非Java应用程序。有什么缺点?锁定问题?格式化?Log4j有一个SocketAppender,它将向服务发送事件,您可以自己实现或使用与Log4j捆绑的简单实现。它还支持syslogd和Windows事件日志,这对于尝试将日志输出与来自非Java应用程序…
    2025-04-161