supabase / auth

A JWT based API for managing users and issuing JWT tokens
https://supabase.com/docs/guides/auth
MIT License
1.3k stars 325 forks source link

Authentication through supabase.auth.signInWithIdToken() is not working. #1358

Closed ganer9r closed 5 months ago

ganer9r commented 6 months ago

Bug report

When using Supabase authentication, currently only browser login is provided, which is inconvenient in terms of usability. I am trying to register using a custom token.

I am currently using Kakao login and attempted to log in using supabase.auth.signInWithIdToken() with a token obtained directly through app login.

I encountered the following error: "error: AuthApiError: Custom OIDC provider "" not allowed"

For other providers like Google and Facebook, the error appears as follows: "error: AuthApiError: Provider (issuer "https://www.facebook.com") is not enabled"

It seems that custom tokens are not supported, as seen here: https://github.com/supabase/gotrue/blob/93e5f82ced83c08799ce99020be9dea82fc56d24/internal/api/token_oidc.go#L76

Considering the setting of for _, allowedIssuer := range config.External.AllowedIdTokenIssuers, I wonder if this might be a bug.

Is the inability to use supabase.auth.signInWithIdToken() with certain providers a bug or a planned feature? How can I log in using signInWithIdToken?

z3rosmith commented 6 months ago

Same here for Kakao login šŸ„²

hf commented 5 months ago

You can't just use sign in with OIDC custom providers just yet. Only a few are supported. Please check the excellent PR #1381 from @MiryangJung on how you can add a new ODIC provider.

Dynamic OIDC providers are coming in 2024, though.

softmarshmallow commented 5 months ago

So atm, we can't use kakao auth for native auth? - using @react-native-seoul/kakao-login

import { Pressable, Image, Alert, Linking } from "react-native";
import { supabase } from "../../lib/supabase";
import {
  KakaoOAuthToken,
  loginWithKakaoAccount,
} from "@react-native-seoul/kakao-login";

const _src = require("../../assets/auth-providers/kakao.png");

export function WithKakao() {
  async function signInWithKakao() {
    console.log("signing in with kakao");
    try {
      const token: KakaoOAuthToken = await loginWithKakaoAccount();
      console.log("token", token);

      const { error, data } = await supabase.auth.signInWithIdToken({
        provider: "kakao",
        token: token.idToken,
        access_token: token.accessToken,
      });

      console.log("data", data);

      if (error) {
        console.error(error);
        Alert.alert(error.message);
        return;
      }
    } catch (error) {
      console.error(error);
    }
  }

  return (
    <Pressable onPress={signInWithKakao}>
      <Image width={40} height={40} source={_src} />
    </Pressable>
  );
}

throws

[AuthApiError: Custom OIDC provider "" not allowed]

Is there no option to signin with id token, while manually providing email which is required info for supabase auth system