无法生成访问令牌和刷新令牌 [英] Unable to generate the Access Token and a Refresh Token

查看:134
本文介绍了无法生成访问令牌和刷新令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行对OneDrive的文件传输自动化.为此,我需要从Microsoft_AAD_RegisteredApps生成访问令牌并刷新令牌.但是,我已经成功完成了前面的所有步骤.

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.

下面是我的POST请求

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 


推荐答案

似乎缺少一些参数,例如scoperedirect_uriclient_secret,但是我没有重现您的问题.因此,我提供了请求的详细信息,以供您参考,在我的测试中,请求成功.

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.

顺便说一句,您的请求似乎有一些小问题.我注意到了另一条帖子你提出来了.根据该帖子中的信息,我认为您可能需要检查Content-Type是否正确,即使您使用了post方法,您似乎也将参数放在查询url中,并跟随请求url.您可能需要将参数放在请求正文中,而不是查询URL中.如果将它们放在查询URL中,然后放在请求URL中,则它们不会在后端代码中检索到.后端代码将首先检索参数grant_type,因此它将始终显示must contain grant_type错误.

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.

希望有帮助〜

这篇关于无法生成访问令牌和刷新令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆