我试图通过传递下面屏幕截图中显示的参数,使用REST API获取访问令牌,但我面临的错误必需的参数缺少:grant_type 。我在Chrome浏览器中尝试使用cURL和高级Rest API。我使用cURL和高级REST API发送这些参数:
I have tried to get an access token using the REST API by passing the parameters which are shown in screenshots below, but I face the error Required parameter is missing: grant_type. I have tried with cURL and the Advanced Rest API in a Chrome browser. I am sending these parameters using cURL and the Advanced REST API:
client_secret;xxx refresh_token; redirect_uri;https%3A%2F%2Fwww%2Eexample%2Ecom%2Foauth2callback scope;www.googleapis/auth/drive client_id;xxxxxxxx.apps.googleusercontent access_token;cURL语法:
D:\>curl -k --header Content-Type=application/x-www-form-urlencoded -i -X POST "accounts.google/o/oauth2/token" -F 'code=4%2FdpbtMVUpzNFAfGHlxrNvfMlvHrPWk_m8y2I-thDdsLk.wvBSFgWEqW0Zcp7tdiljKKZFG-jOlgI' -F 'client_id=xxxxxxxx.apps.googleusercontent' -F 'client_secret=xxx' -F 'redirect_uri=https%3A%2F%2Fwww%2Eexample%2Ecom%2Foauth2callback' -F 'grant_type=authorization_code'如何解决此问题? / p>
How to resolve this issue?
推荐答案显然,您要调用令牌端点来交换代码 access_token 作为授权代码授权的一部分。有几件事:
Apparently you're calling the token endpoint to exchange a code for an access_token as part of an Authorization Code grant. A few things:
添加一些额外的语法优化后,您应该能够使用:
after adding some additional syntax optimization you should be able to use:
curl -v -i \ -d "code=4%2FdpbtMVUpzNFAfGHlxrNvfMlvHrPWk_m8y2I-thDdsLk.wvBSFgWEqW0Zcp7tdiljKKZFG-jOlgI" \ -d 'client_id=xxxxxxxx.apps.googleusercontent' \ -d 'client_secret=xxx' \ -d 'redirect_uri=https%3A%2F%2Fwww%2Eexample%2Ecom%2Foauth2callback' \ -d 'grant_type=authorization_code' \ accounts.google/o/oauth2/token更多推荐
无法获取Google OAuth 2.0访问令牌
发布评论