I have a GMail AddOn that uses OAuth2 for authorization of an external service. When starting the AddOn, I check if the user already has an access token by calling oauthService.hasAccess()
. If the user doesn't have a token, then I'll show a card that says "you need to authorize the service".
The card contain a link built like this:
section.addWidget(CardService.newTextButton()
.setText("Authorize MyService")
.setAuthorizationAction(
CardService.newAuthorizationAction()
.setAuthorizationUrl(authorizationUrl)
));
When the user clicks on the "Authorize MyService" button, a popup window appears and a spinner appears in the old card. Then the user logs into MyService, Authorizes access, and my AuthorizeCallback
gets called with the token. I store the token, and return a HtmlPage that just closes itself.
The spinner in the original card stops spinning. However, the AddOn does not reload. This suggests that there is something preventing the AuthorizationAction card from reloading when the authorization is completed. Any suggestions what that might be?
I want the AddOn to reload because then the entrypoint function will discover that now oauthService.hasAccess()
returns true
, and then will show the normal "you are authorized" card (and start processing the email to MyService).
Thanks for your help!