Office 365统一api对象引用未设置为对象的实例(Office 365 unified api Object reference not set to an instance of an ob

编程入门 行业动态 更新时间:2024-10-28 18:30:44
Office 365统一api对象引用未设置为对象的实例(Office 365 unified api Object reference not set to an instance of an object)

我正在尝试使用新的office365统一api来查询用户列表和用户文件。 我已经在azure管理门户中创建了应用程序,并且我给了新api应用程序的权限(读取了目录和文件)我创建了一个客户端和一个webapi应用程序,试试。

在我的代码中,我使用x509证书来获取令牌,我得到它没有问题。 然后我用curl调用url“ https://graph.microsoft.com/beta/ / users /”来获取用户列表,我得到500错误: 对象引用未设置为对象的实例。 我已尝试过其他网址,而且我也试过直接在firefox中使用相同的标题(授权:bearer等)调用该url,我也遇到了同样的问题。

我已经检查过它是否是授权错误,但它没有缝...如果我省略了授权标题,或者我错了,我收到401错误。 这是我发送到网址的标题: User-Agent:php-microsoft-graph-api / 1.0授权:Bearer ey ...接受:application / json client-request-id:cbe6f962-8b7e-ee4d-a1bc- 34c260cf93ec return-client-request-id:true

我已经尝试使用graphexplorer2应用程序的URL,它工作正常...任何提示或建议调试问题? 谢谢大家

编辑:我忘了说我正在使用客户端凭据流(因为我正在开发一个守护进程)并且我注意到我获得的访问令牌比具有正常身份验证流的令牌短。 ..所以,一个新问题:新的办公室365 api compatbile与客户端凭证流程? 我可以使用任何方法来“验证”我的应用程序,而无需考虑浏览器?

I'm trying to use the new office365 unified api to query the users list and user file. I've created the application in azure management portal, and I gave the permission to the new api application (with the directory and files read) I've created both a client and a webapi application, to try.

In my code, I use a x509 certificate to acquire the token, and I get it without problem. Then I call, with curl, the url "https://graph.microsoft.com/beta//users/" to get the users list, and I get a 500 error: Object reference not set to an instance of an object. I've tried with other urls, and also I've tried call that url, with the same header (the authorization: bearer, etc) directly in firefox, and I've the same problem.

I've checked if it's an authorization error, but it doesn't seam... If I omit the authorization header, or I but a wrong one, I get a 401 error. Here's the header I'm sending to the url: User-Agent: php-microsoft-graph-api/1.0 Authorization: Bearer ey... Accept: application/json client-request-id: cbe6f962-8b7e-ee4d-a1bc-34c260cf93ec return-client-request-id: true

I've tried the url with the graphexplorer2 app, and it work ok... Any hint or suggestion to debug the problem? Thanks to all

EDIT: I've forgot to say that I'm using the client credential flow (because I'm developing a daemon) and I've notice that the access token that I get, is shorter than a token with the normal authentication flow... So, a new question: is the new office 365 api compatbile with client credential flow? There's any method I could use to "authenticate" my app, without passing thought a browser?

最满意答案

Office 365统一API预览中尚不支持客户端凭据流。 它在路线图上。 在此期间,您可以使用app +用户流程。

Client credential flow is not yet supported in the Office 365 unified API preview. It is on the roadmap. In the meantime you can use app + user flows.

更多推荐

本文发布于:2023-08-03 17:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1393656.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   设置为   实例   api   Office

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!