I am trying to get a new access token for clients when ever their current token expires. I have seen some examples that use ruby and some that use javascript but nonei can seem to get any of them to work. I have to be able to do this in either javascript or python as it will live on in a lambda and lambdas can use very few languages. I cant seem to get any of the examples im finding to work for some reason and figure it has to be something just a little off.
var GoogleTokenProvider = require('refresh-token').GoogleTokenProvider;
var tokenProvider = new GoogleTokenProvider({
refresh_token: '1/***************************Xk',
client_id: '930******858-t8683rc*********v2i7efg5o7.apps.googleusercontent.com',
client_secret: 'EM-u_cQJU*******bK16EUa'
});
// Retrieve tokens via token exchange explained above or set them:
oauth2Client.setCredentials({
access_token: 'ya29.Gl**********msfwAwXBWU-EyGWu******************Z2HK9XmBIah20sCT6*************Htm9hPEDBIaml8VW',
refresh_token: '1/************************xMXk',
// Optional, provide an expiry_date (milliseconds since the Unix Epoch)
// expiry_date: (new Date()).getTime() + (1000 * 60 * 60 * 24 * 7)
});
oauth2Client.refreshAccessToken(function(err, tokens) {
// your access_token is now refreshed and stored in oauth2Client
// store these new tokens in a safe place (e.g. database)
console.log(oauth2Client);
console.log("new",tokens);
});
Any help would be appreciated as this is the only thing holding me up to get this project moving forward once again and I gotta figure this out im on a time constraint. I have a few other examples in Javascript I can provide if any body wants to see them. I am really new to pyton so I haven't delved to far in to that but thats what my main function for this part is gonna be in.