【发布时间】:2015-11-28 07:56:59
【问题描述】:
我正在尝试使用我的刷新令牌、客户端 ID 和客户端密码来检索使用 R 代码的 youtube api 的访问令牌。
这是 google 如何发布请求的示例。
POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded client_id=21302922996.apps.googleusercontent.com&client_secret=XTHhXh1SlUNgvyWGwDk1EjXB&refresh_token=1/6BMfW9j53gdGImsixUH6kU5RsR4zwI9lUVX-tqf8JXQ&grant_type=refresh_token
这是我的 r 代码: 库(httr)
url<- paste("https://accounts.google.com/o/oauth2/token?client_id=", client_id, "&client_secret=", client_secret, "&refresh_token=", refresh_token, "&grant_type=access_token", sep="")
POST(url)
我不断收到这样的回复:
日期:2015-09-02 16:43
状态:400
内容类型:application/json
尺寸:102 B
{ “错误”:“无效请求”, "error_description" : "缺少必需参数:grant_type"
有没有更好的方法来做到这一点?也许使用 RCurl?如果是这样,请求的格式是什么?我将不胜感激!
【问题讨论】:
标签: r oauth refresh token youtube-analytics-api