Accessing Microsoft Graph API without using login page

后端 未结 4 1845
闹比i
闹比i 2020-12-10 11:44

I would like to access a user\'s one drive to upload a document or retrieve a document using Graph API. I\'ve seen multiple examples over the net which requires using the st

4条回答
  •  情书的邮戳
    2020-12-10 12:12

    Yes, it is possible if you have the right information - all you need to do is to get a delegated access token.

    Explanation:

    When dealing with access to resources, Microsoft Graph has two levels of access token requirements:

    • Most methods support Application only tokens, meaning once an OAuth app has consent it can access the resource whenever it wants.
    • But for some methods, it is not enough (they are too sensitive for an automated process) and require a Delegated token, meaning token which contains both a valid Client and User. You can see in each method documentation which token it requires.

    Normally delegated access tokens are the result of the two major OAuth flows which require user interaction (Authorization Code Grant and Implicit Grant) but you can also get them from two other flows: Resource Owner Credentials Grant and On-Behalf-Of Grant, which are both supported by Microsoft.

    For a full guide on how to setup everything you need in order to use those flows (including Postman examples) you can look at my article:

    Getting Access Token for Microsoft Graph Using OAuth REST API

提交回复
热议问题