Change Google Account for integrations?

Hi fellow developers,

I am building an integration app that uses Google OAuth authorisation. When a recipe is added, the user is directed to my app feature’s Authorization URL, where I check if there is a refresh token already in my secure storage for that user or not. If not, I am starting the google OAuth flow. Otherwise, I am sending the user to the backToUrl.

Now, once the user has added one recipe, they won’t be directed to the Google OAuth flow anymore while adding any more recipes.

Here is a code snippet of the function that runs on calling the Authorization URL -

const connection = await connectionModelService.getConnectionByUserId(userId);
if(connection?.refreshToken && connection?.mondayToken) {
    return res.redirect(backToUrl);
}

Now, I want to know how I can allow users to change the Google account they wish to use for any recipe?

What is the most common or better UX in this case, and how can I implement it?

I don’t want the user to have to uninstall and re-install the app for this.

I could just direct the user to the Google OAuth flow whenever they add a new recipe regardless of if I have a refreshToken saved from earlier or not, and replace the refreshToken with the new one, but in this case if they had an integration for a google account already and they added a new integration for another google account, the old one might stop working, as the refreshToken was replaced.

So I am unable to think of an approach for this.

1 Like

Add an “Account Settings” feature that allows users to revoke Google auth.

Then also allow that screen to do the OAuth dance again as another user.

If you need to be able to login as multiple different users, allow that on the account settings page, and rather than checking for a refresh token in your integration, check for the number of google accounts and redirect them to a screen where they can choose the Google account they want to use for the automation.

Hi David, thanks for your reply.

That reminded me of the native integration with gmail, where the user gets a screen with a list of logged in google accounts to choose from before adding an automation, or add a new account. Is something like that possible instead of doing all this on the account settings page?