artemklevtsov / RGA

A Google Analytics API client for R
http://cran.r-project.org/package=RGA
32 stars 13 forks source link

Error: Refresh token not available #22

Closed jrangeles closed 8 years ago

jrangeles commented 8 years ago

Hi I'm trying to export data through the get_ga() command but I'm getting the following error:

 Error: Refresh token not available 
6 stop("Refresh token not available", call. = FALSE) 
5 refresh_oauth2.0(self$endpoint, self$app, self$credentials, self$params$user_params) 
4 token$refresh() 
3 validate_token(token) 
2 authorize(client.id = options()$rga$client_id, client.secret = options()$rga$client_secret, 
    reauth = FALSE, cache = "token") 

I think it might have to do with some revoked access I did recently, but I'm not sure how to fix it.

artemklevtsov commented 8 years ago

Try with reauth = TRUE.

jrangeles commented 8 years ago

The re-authentication actually has no problem. The problem is that the token isn't being refreshed and that I have to manually login through the browser to re-activate it.

artemklevtsov commented 8 years ago

I can't reproduce this. Can you provide a steps to reproduce the error?

jrangeles commented 8 years ago

Well I ran authorize() with _withverbose() and this is what I got:

Access token will be stored in the 'token' file.
-> GET /oauth2/v1/tokeninfo?access_token=token_code HTTP/1.1
-> Host: www.googleapis.com
-> User-Agent: libcurl/7.43.0 r-curl/0.9.6 httr/1.1.0
-> Accept-Encoding: gzip, deflate
-> Accept: application/json
-> 
<- HTTP/1.1 400 Bad Request
<- Vary: Origin
<- Vary: X-Origin
<- Content-Type: application/json; charset=UTF-8
<- Content-Encoding: gzip
<- Date: Sat, 20 Feb 2016 17:12:01 GMT
<- Expires: Sat, 20 Feb 2016 17:12:01 GMT
<- Cache-Control: private, max-age=0
<- X-Content-Type-Options: nosniff
<- X-Frame-Options: SAMEORIGIN
<- X-XSS-Protection: 1; mode=block
<- Server: GSE
<- Alternate-Protocol: 443:quic,p=1
<- Alt-Svc: quic=":443"; ma=2592000; v="30,29,28,27,26,25"
<- Transfer-Encoding: chunked
<- 
Error: Refresh token not available

Before the error occurred I actually revoked some GA API access from here https://security.google.com/settings/u/0/security/permissions

You could try revoking your access and see if it also occurs to you.

artemklevtsov commented 8 years ago

You can't use a revoked token anywhere.

jrangeles commented 8 years ago

Revoked in what sense? Because when I run the authorize() function and finish the browser authorization, shouldn't my token be a new one? So why does a refresh token not work even after that?

My case is that after an hour of running the authorize() function, I get the Error: Refresh token not available and would have to re-authorize again. Where as before I don't receive this error and I automatically get the refresh/new token without having to re-authorize through the browser.

artemklevtsov commented 8 years ago

After reauthorise token refreshed without errors.