Closed imrehg closed 10 years ago
Hmmm this could prove tricky. If username+password or keyfile was provided, automatic re-auth could work, though not if the token itself was provided. I think this will need an optional async accessToken
function which can be called to retrieve new keys.
Not sure when, I'll have time to implement this, though PRs are accepted :)
In the mean time, instead of using the spreadsheet
every N minutes, you could spreadsheet.load()
a new one after N idle minutes:
//psuedo code
function getSpreadsheet(callback) {
if(spreadsheet && idleTime < n)
return callback spreadsheet;
Spreadsheet.load(... {
callback spreadsheet
});
}
and then use this function before any interactions
Hi,
I'm using oauth with a key stored in PEM to do server-side login with edit-google-spreadsheets. It looks like that after some time of inactivity, if the program try to read information again, then gets a 401 error
Token invalid - Invalid token: Token not found
.When I had moderate traffic (double digits writes to the spreadsheet / hour) then there didn't seem to be any problem. This came out when I had a low traffic (one event ever few hours).
Now I try to periodically run some commands to the server (a
spreadsheet.receive()
), with a period of 15 minutes, still got the token expiry problem. Testing with "every 5 minutes" interaction to see if that fixes is. Any other way to keep the token valid without manually re-login on such an error?Thanks!