acanessa
acanessa

Reputation: 125

Microsoft Graph - How to obtain token non-interactively?

I want to obtain a token on Microsoft Graph via a GET request. If I use the following call, I get a login screen asking for username and password.

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=f3992025-4d4d-XXXXX-bb2d-XXXXXXXXX
&client_secret=XXXXXXXXXXXXXXXXXXXXXXXXXX
&response_type=code
&redirect_uri=https://10.100.XXX.XXX:5858/authorize
&response_mode=query
&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
&state=12345

if I do so, i do I get the code necessary to later obtain the token and I can use it no without issues

My problem is that I don't want to that login screen. I want the request to return the code without user interaction. I thought that the client_id and client_secret would take care of this.

I am following this directions: https://developer.microsoft.com/en-us/graph/docs/concepts/auth_overview

Thank you.

Upvotes: 1

Views: 776

Answers (1)

axfd
axfd

Reputation: 321

As far as I know, you can use OAuth 2.0 client credentials grant to access web-hosted resources by using the identity of an application.It's is used for server-to-server interactions.For more information, please click https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow.

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
client_id=f3992025-4d4d-XXXXX-bb2d-XXXXXXXXX
&scope=https://graph.microsoft.com/.default
&client_secret=XXXXXXXXXXXXXXXXXXXXXXXXXX
&grant_type=client_credentials

Upvotes: 1

Related Questions