Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when token expires in windows? #26

Open
8steve8 opened this issue Dec 10, 2023 · 1 comment
Open

Issue when token expires in windows? #26

8steve8 opened this issue Dec 10, 2023 · 1 comment

Comments

@8steve8
Copy link

8steve8 commented Dec 10, 2023

#PyError ($(Expr(:escape, :(ccall(#= C:\Users\userName\.julia\packages\PyCall\ilqDX\src\pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'google.auth.exceptions.RefreshError'> #RefreshError('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})

After some time I get stuck with this error in Windows. Manually deleting the pickle files allow me to get past it.... but then some time later I have to do it again.

I can't be sure but I don't think I've seen this error in macOS. I wrote the following code so i don't have to deal with it manually.

  function sheets_client_fixed(authScope::AuthScope)::GoogleSheetsClient
  
      try 
          return sheets_client(authScope)  
      catch e
          @error "error loading client " e
          
          config_dir = joinpath(joinpath(joinpath(homedir(),".julia"),"config"),"google_sheets")
          
          if authScope == AUTH_SCOPE_READWRITE
              filepath = joinpath(config_dir,"google_sheets_token.10.pickle")
          elseif authScope == AUTH_SCOPE_READONLY
              filepath = joinpath(config_dir,"google_sheets_token.0.pickle")
          end
  
          try rm(filepath)
              return sheets_client(authScope)               
          catch e
              println(filepath," file doesn't exist or cannot be deleted")
          end           
      end
  
  end
@JohannesNaegele
Copy link

This is gold, had the same issue on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants