简体   繁体   中英

c# microsoft graph - how to authenticate without login and password?

I'm following the flow described in this site https://github.com/microsoftgraph/msgraph-training-restapi/tree/master/Demos/02-create-app .

but when I access the link below

    https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
         client_id={{REPLACE_APPLICATION_ID}}
         &response_type=code
         &redirect_uri=https%3A%2F%2Flocalhost%3A1234
         &response_mode=query
&scope=openid%20https%3A%2F%2Fgraph.microsoft.com%2Fuser.read%20https%3A%2F%2Fgraph.microsoft.com%2Fcalendars.read
    &state=12345

it shows the "choose an account", so I have to define my user and password.

在此处输入图片说明

after this i can get the url with code described ( https://localhost:1234/?code=.. .)

obs: I have no experience with ms graph lib so there is a possibility that I am following the wrong flow. And I need to develop the code in C#, although I see many examples in asp net mvc.

So, you were able to get the url (localhost:1234?code=...) that represents the authorization code. Now you need to use that authorizaton code to request your OAuth2 Access Token. I would say the easiest way is if you reference this article that guides you step by step on how to do it, using c# as you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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