简体   繁体   English

Outlook REST API-如何检索用户照片

[英]Outlook REST API - How to retrieve a User Photo

I would like to get the photos of my users from outlook and store them in my database. 我想从Outlook中获取用户的照片并将其存储在数据库中。 I want it to be done automatically by the programm with no user interaction required, because i know their email and password. 我希望由程序自动完成此操作,而无需用户交互,因为我知道他们的电子邮件和密码。

I´m trying to use this guide: 我正在尝试使用此指南:

https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#UseaclientlibrarytoaccesstheOutlookRESTAPIGetanaccesstoken https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#UseaclientlibrarytoaccesstheOutlookRESTAPIGetanaccesstoken

I have already registered my website (.NET MVC 5), but I don´t know how to do the authentication and access token part, because half of the links of the guide don´t work and i can´t find any helpful tutorial / code snippets somewhere else. 我已经注册了我的网站(.NET MVC 5),但是我不知道如何执行身份验证和访问令牌部分,因为该指南的一半链接无效,并且找不到任何有用的教程/在其他地方编写代码段。

I´m deeply grateful for any help. 我非常感谢您的帮助。

Instead of using Office 365 REST API, we can use the Microsoft Graph. 除了使用Office 365 REST API,我们还可以使用Microsoft Graph。

And since you don't want to the user participate in the authentication, you can using the Client Credentials Grant Flow which permits a web service (a confidential client) to use its own credentials to authenticate when calling another web service, instead of impersonating a user. 而且,由于您不希望用户参与身份验证,因此可以使用“ 客户端凭据授予流” ,该流程允许Web服务(机密客户端)在调用另一个Web服务时使用其自己的凭据进行身份验证,而无需模拟用户。

Here is the REST API to get the photo for a specific user for your reference: 这是REST API,用于获取特定用户的照片供您参考:

GET:https://graph.microsoft.com/v1.0/users/user1@yourdomain.onmicrosoft.com/photo/$value

The app requires one of the following scopes to request the photo of user: 该应用程序需要以下范围之一才能请求用户照片:

User.Read; User.ReadBasic.All; User.Read.All; User.ReadWrite.All; User.Read

And refer to here to register the app using the Microsoft Graph API. 并参考此处使用Microsoft Graph API注册应用程序。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM