GoogleSheets.jl
GoogleSheets.jl copied to clipboard
Issue when token expires in windows?
#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
This is gold, had the same issue on macOS.