My issue is, upon clicking "Authorize", and the popup window appearing, the "refresh" that checks IsAuthValid() occurs.
This is obviously not ideal, as this refresh should only occur when the window is closed, and the oauth is completed.
It does not occur when the window is closed after the authCallback, but occurs at the beginning, the second the content in the window loads.
Here is the code for creating the OauthService. I believe everything is fairly normal here.
var service = OAuth2.createService(SERVICE_NAME) .setAuthorizationBaseUrl(AUTHORIZATION_BASE_URL) .setTokenUrl(TOKEN_URL) .setClientId(scriptProps.getProperty(CLIENT_ID_PROPERTY_NAME)) .setClientSecret(scriptProps.getProperty(CLIENT_SECRET_PROPERTY_NAME)) .setPropertyStore(PropertiesService.getUserProperties()) .setCallbackFunction("authCallback") .setTokenHeaders({ Authorization:Basic ${bearer_cred}, "Cache-Control": "no-cache", "Content-Type": "application/x-www-form-urlencoded", }) .setTokenPayloadHandler(addParamsToTokenPayload);
here is what I mean by the "refresh" that checks if IsAuthValid() -> which will obviously return false, as the window has literally just been opened and the user has had no chance to finish the oauth flow.
My issue is, upon clicking "Authorize", and the popup window appearing, the "refresh" that checks IsAuthValid() occurs.
This is obviously not ideal, as this refresh should only occur when the window is closed, and the oauth is completed.
It does not occur when the window is closed after the authCallback, but occurs at the beginning, the second the content in the window loads.
Here is the code for creating the OauthService. I believe everything is fairly normal here.
var service = OAuth2.createService(SERVICE_NAME) .setAuthorizationBaseUrl(AUTHORIZATION_BASE_URL) .setTokenUrl(TOKEN_URL) .setClientId(scriptProps.getProperty(CLIENT_ID_PROPERTY_NAME)) .setClientSecret(scriptProps.getProperty(CLIENT_SECRET_PROPERTY_NAME)) .setPropertyStore(PropertiesService.getUserProperties()) .setCallbackFunction("authCallback") .setTokenHeaders({ Authorization:
Basic ${bearer_cred}, "Cache-Control": "no-cache", "Content-Type": "application/x-www-form-urlencoded", }) .setTokenPayloadHandler(addParamsToTokenPayload);
here is what I mean by the "refresh" that checks if IsAuthValid() -> which will obviously return false, as the window has literally just been opened and the user has had no chance to finish the oauth flow.