Search code examples
azureoauth-2.0authorizationidentitybuilder

Is there an OAuth 2 builder for Microsoft identity platform and OAuth 2.0 authorization?


From the documents, the way to request an authorization code is pretty ugly:

// Line breaks for legibility only
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&response_mode=query
&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
&state=12345
&code_challenge=YTFjNjI1OWYzMzA3MTI4ZDY2Njg5M2RkNmVjNDE5YmEyZGRhOGYyM2IzNjdmZWFhMTQ1ODg3NDcxY2Nl
&code_challenge_method=S256

Is there a builder class for this sort of request? Especially considering its going to Azure, I assumed there would be but have been unable to find it.


Solution

  • The second paragraph of that articles states:

    This article describes how to program directly against the protocol in your application using any language. When possible, we recommend you use the supported Microsoft Authentication Libraries (MSAL) instead to acquire tokens and call secured web APIs. Also take a look at the sample apps that use MSAL.

    This article is explaining how the protocol works, but almost nobody is going to implement the protocol directly. MSAL and many other libraries would wrap this functionality for you.