Próbuję utworzyć token OAuth z wiersza poleceń przy użyciu instructions here. Jestem w stanie wykorzystać curl
z linii poleceń i uzyskać prawidłową odpowiedźUżywanie RCurl/httr do Github Basic Authorization
curl -u 'username:pwd' -d '{"scopes":["user", "gist"]}' \
https://api.github.com/authorizations
Teraz chcę powtórzyć to samo w R stosując RCurl
lub httr
. Oto, co próbowałem, ale obie polecenia zwracają błąd. Czy ktoś może wskazać, co tu robię źle?
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'
)
)
w '.opts' liście, spróbuj dodać' httpauth = 1L' –
Spróbuj użyć opisowy flagę, aby zobaczyć dokładnie, co się dzieje – hadley
I 'authenticate' ustaw' type = "podstawowy" ' – hadley