Hi,
I reset my OAuth2 access token this morning, and then refreshed the token. Pasted authorisation url into browser but got the message “The state token is invalid or has expired. Please try again.”
I’ve not changed anything, this has worked fine on numerous occassions.
Any suggestions.
Thanks
Code I am using is below;
function getOAuth2Access() {
var service = getService();
if (service.hasAccess()) {
// … do whatever …
} else {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log(‘Open the following URL and re-run the script: %s’,
authorizationUrl);
}
}
/**
* Configures the service.
*/
function getService() {
return OAuth2.createService(‘hubspot’)
// Set the endpoint URLs.
.setTokenUrl(TOKEN_URL)
.setAuthorizationBaseUrl(AUTH_URL)
// Set the client ID and secret.
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
// Set the name of the callback function in the script referenced
// above that should be invoked to complete the OAuth flow.
.setCallbackFunction(‘authCallback’)
// Set the property store where authorized tokens should be persisted.
.setPropertyStore(PropertiesService.getUserProperties())
.setScope(SCOPE);
}