Search code examples
azure-active-directorymicrosoft-graph-apiaccess-token

Invalid_grant when requesting Access token MS Graph


thanks for reading this.

I've a problem obtaining an access token for MS Graph using Postman. I've been reading similar posts on stackoverflow, but so far, without success. In the following I added some screenshots that contain (I believe) all the information needed for this process.

  1. Screenshot of application permissions: https://i.sstatic.net/4lyM2.png

  2. The link I use to obtain an access-code:

    https://login.microsoftonline.com/{Tenant ID}/oauth2/v2.0/authorize? client_id=3ef3343a-ab22-4c50-12ae2a2d7c67 &response_type=code &redirect_uri=https://localhost:8080 &response_mode=query &scope=offline_access%20user.read &state=12345

3)After following this link I give permission and receive a code, which I use in the following postman call: https://i.sstatic.net/ZJv2b.png

I had no problem obtaining the access token without a user, but unfortunately, I need more than just the application permissions. I hope someone can help me!

Thanks for your time!


Solution

  • You need to delete the "code=" in code of postman call, it looks like "OAAABAAAAiL9Kn.....". code is just the value of "code" from /authorize endpoint. The others all looks correct.


    UPDATE:

    I tried with the steps in your issue, it worked well.

    Permissions:

    enter image description here

    Get authorization code:

    https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize?
    client_id={client-id}
    &response_type=code 
    &redirect_uri=https://localhost:44300/
    &response_mode=query 
    &scope=offline_access%20user.read 
    &state=12345
    

    Receive the code:

    https://localhost:44300/?code=0.ATcATqvJ...vv1MbCO6MN_uCAA&state=12345&session_state=7ac58b8f-b2af-45fa-be4b-0b2c2a003e2e
    

    Code is 0.ATcATqvJ...vv1MbCO6MN_uCAA from the pervious.

    Request in Postman:

    enter image description here