【发布时间】:2013-04-13 20:11:09
【问题描述】:
我正在尝试使用 instructions here 从命令行创建 OAuth 令牌。我可以在命令行中使用curl,并得到正确的响应
curl -u 'username:pwd' -d '{"scopes":["user", "gist"]}' \
https://api.github.com/authorizations
现在,我想使用 RCurl 或 httr 在 R 中复制相同的内容。这是我尝试过的,但两个命令都返回错误。谁能指出我在这里做错了什么?
httr::POST(
'https://api.github.com/authorizations',
authenticate('username', 'pwd'),
body = list(scopes = list("user", "gist"))
)
RCurl::postForm(
uri = 'https://api.github.com/authorizations',
.opts = list(
postFields = '{"scopes": ["user", "gist"]}',
userpwd = 'username:pwd'
)
)
【问题讨论】:
-
在
.opts列表中,尝试添加httpauth = 1L -
尝试使用详细标志来查看到底发生了什么
-
在
authenticate中设置type = "basic" -
httpauth = 1L 有效。仍然无法让
httr工作。 @hadley,我在哪里可以在 httr 的 POST 命令中添加详细信息。 -
rgithub 包在这里可能会有所帮助。