-
I've been successfully using remix-auth with GitHub, Google and email logins. What I'd like to do now is implemented linked accounts, for example if a user logs in with their GitHub account, I want to give the option to link their Google account so I could do things like read their calendar. I'm unclear how to go about this, is this outside of the remit of remix-auth? I've read documentation to trigger a Google sign-in flow, grab the cookies and then invoke the Google APIs but this is done outside of remix-auth, is this the correct way? Anyone has any ideas, or an example, would be greatly appreciated, or even just a broad description of the right approach. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You need to trigger the second strategy, then in the callback of the strategy you can use the request to know if it's already authenticated and link the account, or create a new one. authenticator.use(
new GitHubStrategy(options, async ({ request, tokens }) => {
let profile = await fetchGitHubProfile(tokens)
let currentUser = await queryCurrentUser(request)
if (currentUser) {
await linkAccount(currentUser, profile)
return currentUser;
}
return await createAccount(profile)
})
) |
Beta Was this translation helpful? Give feedback.
You need to trigger the second strategy, then in the callback of the strategy you can use the request to know if it's already authenticated and link the account, or create a new one.