I'm trying to call StackExchange's API, using Google Apps Script and Google Sheets. I can't figure out where in the OAuth process things are going wrong. My current code is not granting access:
function getStackExchangeService_() {
var CLIENT_ID = PropertiesService.getScriptProperties().getProperty('SE_CLIENT_ID');
var CLIENT_SECRET = PropertiesService.getScriptProperties().getProperty('SE_CLIENT_SECRET');
return OAuth2.createService('StackExchange')
.setAuthorizationBaseUrl('https://stackoverflow.com/oauth')
.setTokenUrl('https://stackoverflow.com/oauth/access_token')
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties())
.setRedirectUri('https://stackexchange.com/oauth/login_success')
.setScope('global');
}
When I call this and log the response I always get "false":
var service = getStackExchangeService_();
Logger.log(service.hasAccess());
Thanks for the help!