Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supabase.auth.linkIdentity does not return raw_user_meta_data #1708

Open
2 tasks done
chanmathew opened this issue Aug 4, 2024 · 6 comments
Open
2 tasks done

supabase.auth.linkIdentity does not return raw_user_meta_data #1708

chanmathew opened this issue Aug 4, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@chanmathew
Copy link

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When calling supabase.auth.linkIdentity using the JS client, it does not return and store the raw_user_meta_data that you would normally get when using supabase.auth.signInWithOAuth:

CleanShot 2024-08-04 at 16 06 01@2x

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Sign in an anonymous user
  2. Try to link identity with supabase.auth.linkIdentity
  3. Check the raw_user_meta_data in auth.users

Expected behavior

It should return the metadata just like an oauth sign in.

Screenshots

When using supabase.auth.signInWithOAuth, it returns the raw_user_meta_data:
CleanShot 2024-08-04 at 16 08 06@2x

When using supabase.auth.linkIdentity, it does not return it:
CleanShot 2024-08-04 at 16 06 01@2x

System information

  • Version of supabase-js: 2.44.2
  • Version of Node.js: 20.15.1

Additional context

It would be best if it can be returned as I want my postgres trigger to automatically add the full_name and avatar_url to my public.profiles table once the user's anonymous account has been converted to a permanent account once they've signed in.

@chanmathew chanmathew added the bug Something isn't working label Aug 4, 2024
@j4w8n
Copy link

j4w8n commented Aug 5, 2024

My apologies... commenting again, because my previous one was from the test account.

How are you getting the screenshot output? I tried this with hosted Supabase, looked in the auth.users table in the dashboard, and the user metadata was there for the user. I also console.log'd the returned data from the linkIdentity method, and it also showed the user metadata.

@chanmathew
Copy link
Author

chanmathew commented Aug 5, 2024

@j4w8n I'm getting it in the authentication section, and then looking for my user:
CleanShot 2024-08-04 at 23 02 50@2x

Then I click on view user info:
CleanShot 2024-08-04 at 23 03 06@2x

It's also empty in the actual auth.users table:
CleanShot 2024-08-04 at 23 10 36@2x

I've tried both local dev and in the cloud dashboard, seems like the raw_user_meta_data is empty in both.

@j4w8n
Copy link

j4w8n commented Aug 5, 2024

I'm sorry. I misunderstood what you were saying. I now understand that you mean the metadata that comes back from the OAuth provider.

After converting the user, if I logout and log back in with OAuth, then the data is there, but it would be nice if that data came back during the conversion.

Based on what I see in the data.url of a conversion, it's authorizing directly to the OAuth provider:

'https://github.com/login/oauth/authorize?client_id=<redacted>&redirect_to=http%3A%2Flocalhost%3A5173%2Fself&redirect_uri=https%3A%2F%2F<redacted>.supabase.co%2Fauth%2Fv1%2Fcallback&response_type=code&scope=user%3Aemail&skip_http_redirect=true&state=<redacted>'

Versus an OAuth login data.url:

https://<redacted>.supabase.co/auth/v1/authorize?provider=github&redirect_to=http%3A%2F%2Flocalhost%3A5173%2Fauth%2Fcallback%3Fnext%3D%2Fapp&code_challenge=l3tDoN9qS2u2B3rLXGidmfDcQRga9h3tbhM-w_U21FU&code_challenge_method=s256

I tried to work around it by adding something like ?refresh=true to the redirectTo option on linkIdentity, so I could refresh the session myself, but the redirect never happens - I assume because it's authorizing directly to the provider, and in this case, I couldn't find any redirect url settings for GitHub, so it just sent me back to the app url set in the GitHub OAuth app.

@chanmathew
Copy link
Author

@j4w8n Yeah that's right, the metadata doesn't come back during the conversion.

As for the redirectTo, my understanding is that it only redirects after the authentication, so I just use that to redirect to a specific page within my app.

@jonnylangefeld
Copy link

I just came here because I ran into the same issue.
It is true that if the user logs out and in again after a supabase.auth.linkIdentity the raw_user_meta_data is there, but it should be there even with just linkIdentity.

Any fix or workaround would be appreciated.

@abeisleem
Copy link

Same issue here. Would appreciate a workaround or a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants