question

KaranSharma-8366 avatar image
0 Votes"
KaranSharma-8366 asked vipulsparsh-MSFT commented

Microsoft Graph API unable to get access token, token URL tells me to use /consumers route

Hi, I have created an app in Azure portal using my personal outlook account, I am creating a test app, I have add all the permissions to my app as shown here,
99535-screenshot-5.png


99586-screenshot-6.png


99597-screenshot-7.png


Now I am trying to access the API using postman, however, I am unable to get the correct access token. I keep getting an error stating to use /consumers route. Can anyone assist me with the correct url, I am using the following URL to get the access token: https://login.microsoftonline.com{TenantID}}/oauth2/v2.0/token/
Below is the screenshot of the error.
99528-screenshot-4.png
https://docs.microsoft.com/answers/storage/attachments/99528-screenshot-4.png

However when I use Microsoft Graph Explorer I am able to access all the routes via just logging in, Also I tried using the link https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}&state={random-string}&redirect_uri={redirect-url} to login in my app but I get the error as below
99621-screenshot-8.png


azure-ad-app-registration
screenshot-5.png (97.0 KiB)
screenshot-6.png (83.9 KiB)
screenshot-7.png (82.5 KiB)
screenshot-4.png (111.7 KiB)
screenshot-8.png (288.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

vipulsparsh-MSFT avatar image
0 Votes"
vipulsparsh-MSFT answered KaranSharma-8366 edited

@KaranSharma-8366 Thanks for confirming. If you have registered the app just for personal accounts. Then you will need to use the following endpoints :
https://login.microsoftonline.com/consumers/oauth2/v2.0/token

So under postman, change the URL to reflect above URL while posting.


You can check other endpoints here for the app :

100049-image.png



If the suggested response helped you resolve your issue, please do not forget to accept the response as Answer and "Up-Vote" for the answer that helped you for benefit of the community


image.png (23.7 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KaranSharma-8366 Can you confirm what supported account types you considered while registering the App. You should be able to see this information under Authentication blade for the application.

99754-image.png


If you plan to use a Azure AD account for signing in, you need to make sure that your application uses the organizational accounts options. The consumer endpoint will only understand live/hotmail accounts.

You can change the type accordingly if you go to Authentication blade.


If the suggested response helped you resolve your issue, please do not forget to accept the response as Answer and "Up-Vote" for the answer that helped you for benefit of the community



0 Votes 0 ·
image.png (18.8 KiB)
KaranSharma-8366 avatar image
0 Votes"
KaranSharma-8366 answered KaranSharma-8366 edited

Hi @vipulsparsh-MSFT ,
I only have personal Microsoft account option available in my authentication blade since I am using my personal account for testing
99828-image.png



image.png (121.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.