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.