简体   繁体   English

访问被拒绝。 检查凭据,然后重试

[英]Access is denied. Check credentials and try again

I am trying to access calendar events using the Microsoft Graph API (https://graph.microsoft.com/v1.0/me/calendarView) on node.js following this permissions guide but I receive the error response : 我正在按照此权限指南在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"
    }
}

The call was made with using : 呼叫是使用进行的:

request({url : 'https://graph.microsoft.com/v1.0/me/calendarview',  qs : queryParams, 'auth': {'bearer': token}}, function (error, response, body) {
    ...
});

The request has a valid token and the call to .../me/ via 该请求具有有效令牌,并且通过...调用... / me /

request({url : 'https://graph.microsoft.com/v1.0/me/', 'auth': {'bearer': token}}, function (error, response, body) {
    ...
});

returns : 返回:

{"@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>"}

So I am assuming this is an issue with permissions set on https://manage.windowsazure.com/ where I created two applications, one for the node server and one for the web client application. 因此,我假设这是在https://manage.windowsazure.com/上设置的权限存在的问题,在这里我创建了两个应用程序,一个用于节点服务器,一个用于Web客户端应用程序。 I am using passport for authentication and the client id and secret for the web client application. 我正在使用护照进行身份验证,并使用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) {

Here is what I set for "permissions to other applications" on the node application : 这是我为节点应用程序上的“其他应用程序的权限”设置的内容:

  • Windows Azure Active Directory : Windows Azure Active Directory:
    • Delegated Permissions 委托权限
      • Read all users' full profiles 阅读所有用户的完整资料
      • Sign in and read user profile 登录并阅读用户资料
  • Microsoft graph : Microsoft图形:
    • Delegated Permissions 委托权限
      • Have full access to user calendars 拥有对用户日历的完全访问权限
      • Read user calendars 阅读用户日历
  • (see below) (见下文)
    • Delegated Permissions 委托权限
      • Access 访问

Here is what I set for "permissions to other application" on the web client application : 这是我为Web客户端应用程序上的“其他应用程序的权限”设置的内容:

  • Microsoft Graph : Microsoft Graph:
    • Application Permissions 申请权限
      • Read and write calendars in all mailboxes 在所有邮箱中读取和写入日历
      • Read calendars in all mailboxes 阅读所有邮箱中的日历
    • Delegated Permissions 委托权限
      • Sign users in 登录用户
      • Read user contacts 阅读用户联系人
      • Have full access to user calendars 拥有对用户日历的完全访问权限
      • Read user calendars 阅读用户日历
      • Sign in and read user profile 登录并阅读用户资料
  • Office Exchange 360 Online : Office Exchange 360​​ Online:
    • Application Permissions 申请权限
      • Read and write calendars in all mailboxes 在所有邮箱中读取和写入日历
      • Read calendars in all mailboxes 阅读所有邮箱中的日历
    • Delegated Permissions 委托权限
      • Read user and share calendars 阅读用户并共享日历
      • Read and write user and shared calendars 读写用户和共享日历
      • Read all users' basic profiles 阅读所有用户的基本资料
      • Read user profiles 阅读用户资料
      • Read user contacts 阅读用户联系人
      • Read user calendars 阅读用户日历
  • Windows Azure Active Directory Windows Azure活动目录
    • Application Permissions : none 申请权限:无
    • Delegated Permissions 委托权限
      • Sign in and read user profile 登录并阅读用户资料

I'm not 100% on what the relationship between the permissions set within the azure management portal and specific end point access. 我对Azure管理门户中设置的权限与特定端点访问之间的关系不是100%的了解。 I have read the API scope article but discussion in that article is a bit too conceptual for my needs. 我已经阅读了API作用域文章,但是该文章中的讨论对于我的需求而言太概念化了。

Ultimately I am trying to access and write events to all reservable resources within a tenant id. 最终,我试图访问事件并将其写入租户ID中的所有可保留资源。

I was able to resolve the issue by deleting then regenerating the application through https://manage.windowsazure.com/ then updating the client id and secret. 我能够通过删除然后通过https://manage.windowsazure.com/重新生成应用程序,然后更新客户端ID和密码来解决该问题。 I was, after the fact, able to remove the native client (node) app from the application list and still make the call work. 事实上,我能够从应用程序列表中删除本机客户端(节点)应用程序,并且仍然可以进行通话。

And while I did not use the reference https://jwt.io/ provided by Fei Xue, I assume it will be invaluable for debugging azure to API permissions in the future. 虽然我没有使用Fei Xue提供的参考https://jwt.io/ ,但我认为它对于将来调试Azure权限到API权限将是非常宝贵的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Graph API,删除请求响应错误代码 403“”访问被拒绝。 检查凭据并重试。” - Microsoft Graph API, DELETE request response Error code 403 “”Access is denied. Check credentials and try again." 节点:权限被拒绝。 怎么修? - node: permission denied. How to fix? Facebook messenger聊天机器人显示“检查您的连接,然后重试。” - Facebook messenger chatbot shows “Check your connection and try again.” 生成器权限被拒绝。 无法在 Google Cloud 上部署 - Builder Permission denied. Unable to deploy on Google cloud JS如果出现错误,请重试 - JS try again if error IBM Watson Visual Recognition API,Node.js:未经授权:由于凭证无效,访问被拒绝 - IBM Watson Visual Recognition API, Node.js: Unauthorized: Access is denied due to invalid credentials “错误:未经授权:由于凭据无效而拒绝访问。” Watson视觉识别 - “Error: Unauthorized: Access is denied due to invalid credentials.” Watson visual recognition IBM Watson Visual Recognition (NodeJS) - 错误代码 403:禁止:访问因凭证无效而被拒绝 - IBM Watson Visual Recognition (NodeJS) - Error code 403 : Forbidden: Access is denied due to invalid credentials ER_ACCESS_DENIED_ERROR:当我尝试连接到远程服务器上的数据库时 - Node.js - ER_ACCESS_DENIED_ERROR: When i try to connect to the database on remote server - Node.js 我尝试将 MySQL 与 nodejs 连接,但错误:用户 'root'@'localhost' 的访问被拒绝(使用密码:是) - I try to connect MySQL with nodejs but Error:Access denied for user 'root'@'localhost' (using password: YES)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM