supabase-kt: [Bug]: Can't login with google in desktop and ios
General Info
- I checked for similar bug report
- I am using the latest version
- I checked the troubleshooting page for similar problems
Version(s)
3.1.4
Kotlin Target(s) and their respective versions
JVM 17, iOS 18.4, Android 15
What happened? (include your code)
Error description
I’m following this documentation to sign in with Google. It works normally in Android, but in iOS and on Desktop, it doesn’t work.
Desktop
iOS
The internet is ok, since it opens other URLs normally.
My Google Cloud configuration
The doc suggests using the web client URL, I’m using it in the code, and my Google Cloud web client already has the configuration for trust URLs / hosts
My Supabase Google login configuration
- I added all 4 (Android, iOS, web and Desktop) client IDs separated by a comma in Client IDs field
- Client Secret (from web client)
- Using the same Callback URL
https://tasegsimjwhvplfgfahd.supabase.co/auth/v1/callbackin Authorized redirect URIs
Code
Here are the relevant parts of the code that I’m using to configure it:
class LoginViewModel : ViewModel() {
private val _action: MutableSharedFlow<LoginAction> = MutableSharedFlow()
val action: SharedFlow<LoginAction> = _action
val supabaseClient: SupabaseClient = createSupabaseClient(
supabaseUrl = SUPABASE_URL,
supabaseKey = SUPABASE_API_KEY,
) {
install(Auth)
install(ComposeAuth) {
googleNativeLogin(serverClientId = WEB_GOOGLE_CLIENT_ID)
}
}
fun onSignInResult(result: NativeSignInResult) {
viewModelScope.launch {
_action.emit(
when (result) {
NativeSignInResult.ClosedByUser -> LoginAction.ShowError("Closed by user")
is NativeSignInResult.NetworkError -> {
logError(result.message)
LoginAction.ShowError(result.message)
}
is NativeSignInResult.Error -> {
logError(result.message)
LoginAction.ShowError(result.message)
}
NativeSignInResult.Success -> LoginAction.GoToMain
}
)
}
}
// ...
@Composable
fun LoginScreen(
viewModel: LoginViewModel,
goToMain: () -> Unit,
) {
val authState = viewModel.supabaseClient.composeAuth.rememberSignInWithGoogle(
onResult = viewModel::onSignInResult
)
// ...
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20
yep thats correct. If you check for the
Authenticatedstatus: You can usestatus.isNewto check if this status comes from a Sign In (true) or any other source (like Storage etc) (false)https://supabase.com/docs/reference/kotlin/auth-onauthstatechange