0
votes

I am searching for the Microsoft graph API to get login and get token. What i have got is the API login via client id and client secret. But i haven't got any API to login using client id and certificate and thumbprint.

Where i have searched for API https://docs.microsoft.com/en-us/graph/auth-v2-user?context=graph%2Fapi%2F1.0&view=graph-rest-1.0#endpoint-considerations

1

1 Answers

0
votes

You should refer to the Client credentials flow documentation for info on this. Specifically this part.

Example of the raw request from the docs:

POST /{tenant}/oauth2/v2.0/token HTTP/1.1               // Line breaks for clarity
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded

scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
&client_id=97e0a5b7-d745-40b6-94fe-5f77d35c6e05
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=eyJhbGciOiJSUzI1NiIsIng1dCI6Imd4OHRHeXN5amNScUtqRlBuZDdSRnd2d1pJMCJ9.eyJ{a lot of characters here}M8U3bSUKKJDEg
&grant_type=client_credentials

The main thing that is a bit complicated here is the assertion, which you can read about here.

If you use e.g. MSAL.NET, it's a lot easier though (reference):

IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(clientId)
    .WithCertificate(certificate)
    .WithRedirectUri(redirectUri)
    .Build();

// Use app object to acquire tokens