In the Microsoft Graph API Access Token Request how do we get the value for the required &code parameter?

Chad Saar 21 Reputation points
2022-02-02T19:46:28.69+00:00

I am following the Get Auth Tokens documentation where it has you register your application and then provides an HTTP request that needs to be made. In the request, one of the required paramaters is called &code and the documentation completley omits where we would find thsi value.

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Zehui Yao_MSFT 5,876 Reputation points
    2022-02-03T03:12:17.257+00:00

    Hello @Chad Saar , it's true this part is not mentioned in the documentation, before getting the token, you need to be authorized. Paste the request below into your browser and run.
    170766-image.png
    After consent, the page will refresh, and the Authorization response will appear in the URL, which contains the code.
    170737-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Chad Saar 21 Reputation points
    2022-02-03T16:45:53.517+00:00

    unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.

    We registered our app on the Azure portal already as a Web application. That is how we got the Client ID (Application ID) and Secret.


  2. Chad Saar 21 Reputation points
    2022-02-07T21:04:10.173+00:00

    We did not have the 3rd or 4th option, but the second option worked for us. We were able to get the code. I would recommend adding this to the documentation, otherwise the next person who wants to use the API will not know how to get the code. Without a code you can't get an access token, and without an access token you can never authenticate to call any of the methods.

    Thanks for helping out though!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.