2016-04-20 11 views
0
library(httr) 
library(httpuv) 
library(jsonlite) 
myapi <- oauth_app("github", "0b23485d6d6e55143372", 
        secret = "xxxxxxxxxxxxxxxxxxxxxxx") 
github_token <- oauth2.0_token(oauth_endpoints("github"), myapi) 
request1 <- GET("https://api.github.com/users/jtleek/repos", config(token = github_token)) 
myjson <- content(request1) 
myjson2 <- jsonlite::fromJSON(toJSON(myjson)) 
View(myjson2) 
stop_for_status(request1) 

私はR 3.2.5とWin7の32ビットを使用するエラー。 2つの問題があります。 1つはコードの最後の行の後に、私はエラーエラー:不正(HTTP 401)を取得しました。最後にRはgithubのAPIにconncetするが、資格情報が

And the second is when I tried to see what the github_token is, 
<Token> 
<credentials> error, error_description, error_uri 

myjson2データフレームが、単にリスト

$message 
[1] "Bad credentials" 

$documentation_url 
[1] "https://developer.github.com/v3" 

おかげでたくさんではありません!

答えて

1

私は同じ問題を抱えていたので、githubページに新しいキーと秘密のセットが作成されました。ところで、私はあなたがjsonlite ::を使って変換する必要はないと思うので、フォーマットはうまくいくはずです。私は以下を使用した:

gtoken <- config(token = github_token) 
req <- with_config(gtoken, GET("https://api.github.com/users/jtleek/repos")) 
con_req <- content(req) 

find_create <- function(x,myurl) { 
    if (x$html_url == myurl) { 
    print(x$created_at) 
    } 
} 

lapply(con_req,find_create,myurl ="https://github.com/jtleek/datasharing") 
関連する問題