I am not able to end the authentication process in the data studio, it is not calling the success screen, authCallback () funcction. The authorize button appears on the data studio screen but does not update and allows connection.Documentation link
Follow the code
function getOAuthService(){
clearProperties(userProperties);
var scriptProps = PropertiesService.getScriptProperties();
credenciais = new getConta();
var clientId = credenciais.CLIENT_ID;
var clientSecret = credenciais.CLIENT_SECRET;
//var objSetHash = new setHash();
var State = setHash();
return OAuth2.createService('ContaAzul')
.setAuthorizationBaseUrl('https://api.contaazul.com/auth/authorize?state=' + State)
.setTokenUrl('https://api.contaazul.com/oauth2/token')
.setClientId(clientId)
.setClientSecret(clientSecret)
.setPropertyStore(PropertiesService.getUserProperties())
.setCache(CacheService.getScriptCache())
.setScope('sales')
.setCallbackFunction('authCallback')
// Set the response type to code (required).
.setParam('response_type', 'code');
}
function resetOAuth(){
var service = getOAuthService();
service.reset();
}
function get3PAuthorizationUrls() {
return getOAuthService().getAuthorizationUrl();
// Logger.log(retorno);
// return retorno;
}
function isAuthValid() {
return getOAuthService().hasAccess();
// Logger.log(acesso);
// return acesso;
}
/*final conforme documentação[![inserir a descrição da imagem aqui][1]][1]*/
function authCallback(request) {
var isAuthorized = getOAuthService().handleCallback(request);
if (isAuthorized) {
return HtmlService.createHtmlOutput('Success! You can close this tab.');
} else {
return HtmlService.createHtmlOutput('Denied. You can close this tab');
}
}