1
votes

I'm trying to perform a file transfer automation to OneDrive. For that, I need to generate an access token and refresh token from the Microsoft_AAD_RegisteredApps. However, I completed all the previous steps successfully.

Below is my POST REQUEST

POST /common/oauth2/v2.0/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 119

grant_type=authorization_code&client_id=XXXXXXXXXXXXXXXXXXXXX&code=XXXXXXXXXXXXXXXX
```. 
client_id -> Client ID generated from the APP
code -> Code generated by the below url

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=your_app_client_id&response_type=code&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient&response_mode=query&scope=User.Read%20offline_access%20Files.ReadWrite

Unfortunately I'm getting 404  always as response. May I know what is missing my code or I miss any certification or license. Anyway please help me to find out the issue 


1

1 Answers

0
votes

It seems missing some parameters such as scope, redirect_uri and client_secret, but I didn't reproduce your problem. So I provide the details of my request for your reference, in my test the request is successful.

enter image description here

For further information about authorization code flow, you can refer to this tutorial.

By the way, it seems there are some minor problems in your request. I noticed another post you raised. According to the information from that post, I think you may need to check if the Content-Type is right and it seems you put the parameters in the query url follow the request url even if you used post method. You may need to put the parameters in the request body but not in the query url. If you put them in the query url follow the request url, they will not be retrieved in the backend code. The backend code will retrieve the parameter grant_type first, so it will always show must contain grant_type error.

Hope it helps~