Unable to generate the Access Token and a Refresh Token

人走茶凉 提交于 2020-05-16 02:29:05

问题


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:


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.

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~



来源:https://stackoverflow.com/questions/61461135/unable-to-generate-the-access-token-and-a-refresh-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!