supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
656 stars 154 forks source link

AuthException(message: Internal Server Error, statusCode: 400) #910

Closed TheCarpetMerchant closed 1 month ago

TheCarpetMerchant commented 1 month ago

Describe the bug AuthException(message: Internal Server Error, statusCode: 400)

To Reproduce

final googleSignIn = GoogleSignIn(
      serverClientId: 'MY_WEB_CLIENT_ID',
);
final googleUser = await googleSignIn.signIn();
final googleAuth = await googleUser!.authentication;

final rep = await supabase.auth.signInWithIdToken(
  provider: OAuthProvider.google,
  idToken: googleAuth.idToken!,
  accessToken: googleAuth.accessToken,
);

Expected behavior A user should get created on Supabase with the signInWithIdToken call. No user is created, all tables in the auth db are empty. The logs show the following info : POST | 400 | IP | 87b862e13f2dbXXX | https://[project_id].supabase.co/auth/v1/token?grant_type=id_token | Dart/3.3 (dart:io) I can provide more info by email if necessary. To note : The error occurs whether the Android OAuth client id is provided or not.

Version (please complete the following information):

????????? supabase_flutter 2.5.1
???   ????????? supabase 2.1.1
???   ???   ????????? functions_client 2.0.0
???   ???   ????????? gotrue 2.6.0
???   ???   ????????? postgrest 2.1.1
???   ???   ????????? realtime_client 2.0.4
???   ???   ????????? storage_client 2.0.1

Additional context The google sign in proceeds correctly. The problem occurs on Supabase. image

dshukertjr commented 1 month ago

@TheCarpetMerchant

The error occurs whether the Android OAuth client id is provided or not.

This makes me think that the wrong client IDs might be pasted on the wrong place, because there is no where to paste the Android client IDs. Please read the docs again, make sure you have followed the steps the exact same way, and if you are not able to solve it then, then please respond to the following questions providing as much details as possible.

TheCarpetMerchant commented 1 month ago

Hello,

I only tried to add the Android client ID after I got the error when using only the web client ID. Same thing with the Client Secret and Client ID fields in the supabase UI, I added them after using only the web client ID proved unsuccessful.

I followed the steps outlined at https://youtu.be/utMg6fVmX0U, section without Firebase, to create the client ids. I pasted them as shown in the screenshot and code.

The actual problem here is that Supabase goves absolutely no information on what went wrong.

dshukertjr commented 1 month ago

@TheCarpetMerchant Well, we cannot tell what client ID is pasted where from the screenshot, so I asked the question here. We kindly ask you to corporate and respond to the questions if you would like assistance.

TheCarpetMerchant commented 1 month ago

Yes, I did paste the correct ID. Worth noting is that upon coming back to the Providers page, Supabase has moved the pasted wbneb client id to the Client ID field.

dshukertjr commented 1 month ago

@TheCarpetMerchant The authorized client ID moving up to the Client ID field is not an issue. They are the same thing as far as the backend is concerned.

The important question is, when you got the error, what Client ID did you have on what field? Also, could you confirm that you are testing this on an Android device/ emulator.

TheCarpetMerchant commented 1 month ago

I am using the web client id, as shown in my code snipet above. I am using an Android API 33 Google Play 64 bits emulator.

Edit : Additionally, what can I do to know what's the actual error ? "Internal error" is not worth anything as an error message.

TheCarpetMerchant commented 1 month ago

I just tried creating a new user by email/password with the signUp function, and got this error : {\"code\":500,\"error_code\":\"unexpected_failure\",\"msg\":\"Database error saving new user\",\"error_id\":\"87c17ea583ff2e2c-BRU\"} Now this is already a way more informative message, if still of quite poor quality. I thought that maybe the whole user creation was done in a transaction, which made sense, and that the trigger I had made to automatically create a row in my own users table could create an error (despite it being extremely simple). I dropped it, and now I'm getting a 429 error. The logs do not give anymore info (and by the way, they're basically unreadable on Firefox).

Overall, I have to say this is an extremely poor experience. If I was looking for a backend for an Entreprise project, Supabase would have been dropped if only due to the very poor logs and errors.