2014-11-30 6 views
0

해들리의 R google Oauth2.0 데모를 따라 퓨전 테이블에 액세스 할 때 새로 고침 토큰을 사용할 수 없습니다.R httr Google 데모로 Oauth 2.0 새로 고침 토큰 검색

데모 : 수정 "오프라인"시도의 https://github.com/hadley/httr/blob/master/demo/oauth2-google.r

예 : 새로 고침 토큰을 검색하는 방법에 대한 방향이 많이 감사합니다

google_token <- oauth2.0_token(oauth_endpoints("google"), myapp, 
          scope = "https://www.googleapis.com/auth/fusiontables", 
          type= "offline", 
          use_oob = FALSE, 
          cache = TRUE) 

.

업데이트 : 다음 코드를 사용하면 google_token $ credentials을 사용하여 문자열을 반환합니다. 여기에 참조 된 인증 코드입니까? https://developers.google.com/accounts/docs/OAuth2WebServer#offline

google_token <- oauth2.0_token(oauth_endpoints("google"), myapp, 
          scope = "https://www.googleapis.com/auth/fusiontables", 
          type= "access_type='offline'", 
          use_oob = FALSE, 
          cache = TRUE)  

고맙습니다.

답변

1

나는 파티에 약간 늦었지만 잘하면이 도움이된다. 나는 지난 주에 같은 문제로 고심하고 있었기 때문에이 질문을 발견했다. API 문서를 읽고 "oauth2.0_token()"함수의 "type"필드에서 "offline"을 시도했지만 응답이 엉망입니다. github 저장소에서 httr 패키지 소스 파일을 다운로드하고 둘러 보았습니다. 약간 파기 후에 나는 그것의 주위에 방법을 찾아 냈다.

이에서 OAuth를-초기화에서 "권한을 부여-URL을"변수 수정하면이에

authorize_url <- modify_url(endpoint$authorize, query = compact(list(
    client_id = app$key, 
    scope = scope_arg, 
    redirect_uri = redirect_uri, 
    response_type = "code", 
    state = state))) 

:

authorize_url <- modify_url(endpoint$authorize, query = compact(list(
    client_id = app$key, 
    scope = scope_arg, 
    redirect_uri = redirect_uri, 
    response_type = "code", 
    state = state, 
    access_type="offline"))) 

를 다음의 OAuth 토큰 및 모든 종속 기능을 소스 (oauth-init 포함) 새로 고침 토큰을 얻습니다. 어떤 이유로 oauth_token이 init_oauth2.0을 호출 할 때 "type"인수를 전달하지 않습니다.

그것은 불쾌한 해결 방법이며 여러 죄를 저질렀지만 제대로 작동합니다. 새로 고침 토큰을 얻습니다.