我正在尝试使用此处的说明从命令行创建 OAuth 令牌。我可以curl
从命令行使用,并得到正确的响应
curl -u 'username:pwd' -d '{"scopes":["user", "gist"]}' \
https://api.github.com/authorizations
现在,我想在 R 中使用RCurl
or复制相同的内容httr
。这是我尝试过的,但两个命令都返回错误。谁能指出我在这里做错了什么?
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'
)
)