Skip to content

linkIdentity() does not work with React Native #1645

Open

Description

@norenz92

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

Not sure if this is a bug or just not compatible with React Native, but there is no way to use linkIdentity() with native social logins like Google, Facebook and Apple in a React Native app. Documentation does not provide any information on how to implement this.

System information

  • OS: macOS
  • Version of supabase-js: 2.44.2
  • Version of Node.js: v20.5.1

Activity

  1. added
    bug
    on Jul 3, 2024
  2. kangmingtay commented on Jul 3, 2024

    @kangmingtay
    Member

    no way to use linkIdentity() with native social logins like Google, Facebook and Apple in a React Native app

    @norenz92 can you elaborate more on this statement? do you get some sort of error when you call linkIdentity in a react native environment?

  3. norenz92 commented on Jul 4, 2024

    @norenz92
    Author

    no way to use linkIdentity() with native social logins like Google, Facebook and Apple in a React Native app

    @norenz92 can you elaborate more on this statement? do you get some sort of error when you call linkIdentity in a react native environment?

    No error. It's just that this function does not seem to be meant to use with native auth for these providers. The function returns a redirect URL which from AFAIK has no use in my case.

  4. kangmingtay commented on Jul 4, 2024

    @kangmingtay
    Member

    @norenz92 it works just like signInWithOAuth(), where you need to redirect the user to the URL returned

  5. norenz92 commented on Jul 9, 2024

    @norenz92
    Author

    @norenz92 it works just like signInWithOAuth(), where you need to redirect the user to the URL returned

    I don't want to redirect the user to a browser from the app...

  6. f-bog commented on Jul 19, 2024

    @f-bog

    @norenz92 I was confused in a similar way, you will need to utilise something like expo-web-browser to prompt open an in-app browser to handle the redirecting. This seems to be the standard way to handle social logins inside of apps.. I'm not aware of a different solution.

  7. zwenza commented on Jul 23, 2024

    @zwenza

    Linking works also in React Native with the standard OAuth flow over the web-browser, for anyone interested, this is how I got it to work, linking the user through an in-app browser:

    const { data, error } = await supabase.auth.linkIdentity({
      provider: "apple",
      options: {
        skipBrowserRedirect: true,
        redirectTo: "<YOUR_APP_DEEPLINK>",
      },
    });
    
    if (data.url) {
      await WebBrowser.openAuthSessionAsync(
        data.url,
         "<YOU_APP_DEEPLINK>"
      );
    }

    However I agree with @norenz92 that this could be improved. Supabase already has capabilities to support native sign-in methods on mobile platforms (see docs).

    Currently I can already offer a native sign-in this way using expo-apple-authentication:

    const credential = await AppleAuthentication.signInAsync({
      requestedScopes: [AppleAuthentication.AppleAuthenticationScope.EMAIL],
    });
    
    // This works for non-anonymous signups
    await supabase.auth.signInWithIdToken({
      provider: "apple",
      token: credential.identityToken,
    });
    
    // This is how I would imagine linkIdentity to support native sign-ins 
     const { data, error } = await supabase.auth.linkIdentity({
      provider: "apple",
      token: credential.identityToken,   // This is currently not possible!
      options: { skipBrowserRedirect: true },
     });

    Is there anything speaking against allowing us to pass the OIDC token to linkIdentity like we can already do with signInWithIdToken?

  8. christophemenager commented on Nov 18, 2024

    @christophemenager

    +1 on this! Having the possiblity to linkIdentity with a token property would be amazing. Linked issue https://github.com/orgs/supabase/discussions/29017

  9. ndrkltsk commented on Jan 21, 2025

    @ndrkltsk

    Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions