I’ve recently started playing around with Supabase coming from Firebase and I like it. I’m leaning towards fully migrating because of its Postgres db which I think is a plus. But one thing I can’t find a solution to is how to convert an anonymous user to a non-anonymous one by linking it to a Google account.
I already have both Google sign-in set up using google_sign_in, and anonymous sign-in working but I’m confused as to how to merge both.
I have manual linking enabled but running this from an anonymous user:
await supabase.auth.linkIdentity(OAuthProvider.google);
throws:
AuthException(message: Unsupported provider: missing OAuth secret, statusCode: 400)
I can’t use signInWithIdToken()
to link an anonymous account to google because it creates a brand new user from scratch. The user id needs to be retained because there may already be data from it:
...
// BAD: Creates new user with new id
final supabase = Supabase.instance.client;
return supabase.auth.signInWithIdToken(
provider: OAuthProvider.google,
idToken: idToken,
accessToken: accessToken,
);
Where exactly do I get the OAuth secret and should I be using signInWithOAuth()
instead of signInWithIdToken()
for google accounts? Appreciate the help guys.