1
votes

I'm trying to register an application in Azure AD using Graph API with an oauth token obtained with the Authorization Code grant type. I can do it with Client Credentials, but not with Authorization Code. With the latter I can list applications, but not create them. Here's the permissions I've set in the application: App permission

And here's what I set in postman to get the token: Postman Authorization

I get the token just fine and I can list the applications, but when I try to create a new one through the endpoint 'POST https://graph.microsoft.com/v1.0/applications' I get the following response: Postman's response to the POST request

Anyone knows why this is happening? Thanks!

1

1 Answers

0
votes

According to the last screenshot you provided, it seems the process stopped at login page(the response body is the html of login page) when do authorization code flow.

I test it in my side(also in postman) but it works fine, below is my configuration in postman for your reference:

enter image description here

enter image description here

Although I didn't reproduce your problem in my test, but I can provide you some information about authorization code backend request to know what does the response in your postman mean.

When we do authorization code flow(not in postman) to get access token, there are two steps. First we need to request the url https://login.microsoftonline.com/{tenantId or commone}/oauth2/authorize?resource=https://graph.microsoft.com&client_id={clientId}&response_type=code&redirect_uri=https://hurytest&response_mode=query in your browser like below screenshot. enter image description here

We can find the content in the red box in screenshot above is same to the response you get in postman. So I think the process stopped here(which is the first step of authorization code flow).

Second step, we need to input username and password into the login page. It will redirect to another page like below screenshot. enter image description here

Copy the code after code= in the above screenshot and then use the code in below request to get access token.

enter image description here

In a word, I didn't reproduce your problem in my postman. But the backend request in your postman may stopped in the first step(login page) of authorization code flow which I mentioned above. So please check if you configured correct in postman. If still doesn't work, you can do authorization code flow by the two steps I provided to get the access token.