oauth - authorization code for Github API used in R -


i trying access api information on http://github.com. created in application in github (in developer application) url , try access thru r using httr libraries. following code

library(httr) oauth_endpoints("github") myapp <- oauth_app("github",key = "#####################",secret = "########################" ) 

(key replaced client id , secret replaced secred id)

github_token <- oauth2.0_token(oauth_endpoints("github"), myapp) 

this prompted me following

use local file cache oauth access credentials between r sessions? 1: yes 2: no

i selected 2 (as tried option 1 earlier) following displayed

httpuv not installed, defaulting out-of-band authentication please point browser following url:     https://github.com/login/oauth/authorize?client_id=72939e1b6d499f4f1894&scope=&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code 

enter authorization code can 1 tell me authorization code is?

the authorisation code code github supplies after correct oauth 2.0 'dance' (to use hadley wickham's term). easiest way of doing use httpuv (install.packages("httpuv")). installed, local webserver setup on port 1410 , provided you've setup github application appropriately (with redirect http://localhost:1410).

if don't have httpuv installed, httr's oauth 2.0 function defaults out of band authorisation. asks github redirect urn:ietf:wg:oauth:2.0:oob&response_type=cod should display authorisation code within browser can copied , pasted. however, you've got different set redirect url , github complains there redirect uri mismatch. i'm not sure whether github can configured allow oob redirect (but i've tried , doesn't seem to).

the reasons not use httpuv if using r on machine won't let set server on port 1410 or if using r on remote machine via rstudio server or ssh session. in latter case, webserver setup on remote machine, browser trying connect port 1410 on local machine. potentially around doing ssh port forwarding port 1410 on local machine port 1410 on remote machine.

note demo code @ https://github.com/hadley/httr/blob/master/demo/oauth2-github.r unlike current cran version of oauth2-github demo includes secret hadley's application can run demo without setting own application first.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -