具有正确令牌的 ResourceNotFound Microsoft Graph Api [英] ResourceNotFound Microsoft Graph Api with correct token

查看:139
本文介绍了具有正确令牌的 ResourceNotFound Microsoft Graph Api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有用户的情况下在我的应用程序中使用 microsoft graph API.因为我使用此 url 通过租户 ID (a8ef7dd1-217d-430f-9ba0-4dd465b9098d) 获得访问令牌

I want to use microsoft graph API in my application without user. For I got access token by tenant id (a8ef7dd1-217d-430f-9ba0-4dd465b9098d) using this url

https://login.microsoftonline.com/a8ef7dd1-217d-430f-9ba0-4dd465b9098d/oauth2/v2.0/token

我在此请求后看到了正确的结果.在我尝试让用户使用此 url 之后https://graph.microsoft.com/v1.0/users

I see correct result after this request. Afte that I try to get user using this url https://graph.microsoft.com/v1.0/users

它对我来说也很好用.响应示例:{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","value":[{"businessPhones":[],"displayName":"IOTA CLM","givenName":"IOTA","jobTitle":null,"邮件":null,"mobilePhone":null,"officeLocation":null,"preferredLanguage":null,"surname":"CLM","userPrincipalName":"clm-iota_outlook.com#EXT#@clmiotaoutlook.onmicrosoft.com","id":"50ecbaed-9cee-411f-abb6-5e53e2a1051a"}]}

It also works fine for me. Example response: {"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users","value":[{"businessPhones":[],"displayName":"IOTA CLM","givenName":"IOTA","jobTitle":null,"mail":null,"mobilePhone":null,"officeLocation":null,"preferredLanguage":null,"surname":"CLM","userPrincipalName":"clm-iota_outlook.com#EXT#@clmiotaoutlook.onmicrosoft.com","id":"50ecbaed-9cee-411f-abb6-5e53e2a1051a"}]}

但是如果我尝试使用下一个获取请求获取邮件文件夹

But if I try to get mailFolders using next get request

https://graph.microsoft.com/v1.0/users/50ecbaed-9cee-411f-abb6-5e53e2a1051a/mailFolders

我看到 404 错误:

I see 404 error :

"code": "ResourceNotFound","message": "无法发现资源."

"code": "ResourceNotFound", "message": "Resource could not be discovered."

我错过了什么?

推荐答案

您确定该用户有邮箱吗?

Are you sure that that user has a mailbox?

确保您拥有正确的权限?要访问邮件,您需要获得管理员同意的 Mail.Read 应用程序权限.https://docs.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0

Make sure you have the correct permissions? To access mail, you require Mail.Read application permissions that have been admin consented. https://docs.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0

您可以在应用程序的权限"选项卡中的门户中注册应用程序的位置进行管理员同意.https://aad.portal.azure.com

You can admin consent where you've registered the application in the portal in the "Permissions" tab of the application. https://aad.portal.azure.com

这篇关于具有正确令牌的 ResourceNotFound Microsoft Graph Api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆