supabase-community/supabase-csharp

OAuth + Supabase + Native Android(MAUI, Xamarin Forms, Xamarin Android)

Phantom-KNA opened this issue ยท 12 comments

I have implemented authentication with Google in Android, I am using SignInWithIdToken passing Google's response IdToken or RequestIdToken as a parameter but it gives an error, that I am missing.

{"error":"invalid request","error_description":"Bad ID token"}

Well i found the problem. If is possible when i can create a new documentation for new user. This is the example for Xamarin Android, Xamarin Forms, or MAUI.

`string identityToken = Encoding.UTF8.GetString(System.Text.Encoding.UTF8.GetBytes(GoogleOrAppleIdToken), 0, GoogleOrAppleIdToken.Length);

var user = await Supabase.Auth.SignInWithIdToken(Provider.Google, identityToken);`

@acupofjose
@rhuanbarros

Well this method SignInWithIdToken only work for existing user. Any comment for New User with OAuth Native Android?

Double check to make sure Project Settings -> Auth -> User Signups is turned on. Other than that not sure off the cuff, possible something isn't quite right in the choreography hitting the server and getting the session back. If you have the cycles right now you can try checking with a debugger to see if the API from the server is returning a response or not...

https://github.com/supabase-community/gotrue-csharp/blob/f3695d5abbf35e4f0b59ef744e42f664cfb535cb/Gotrue/Client.cs#L200

Also btw I've used that method for the native Sign in with Apple flow but not the OAuth flow, very interesting to doc that flow...

string identityToken = Encoding.UTF8.GetString(System.Text.Encoding.UTF8.GetBytes(GoogleOrAppleIdToken), 0, GoogleOrAppleIdToken.Length);

Double check to make sure Project Settings -> Auth -> User Signups is turned on. Other than that not sure off the cuff, possible something isn't quite right in the choreography hitting the server and getting the session back. If you have the cycles right now you can try checking with a debugger to see if the API from the server is returning a response or not...

https://github.com/supabase-community/gotrue-csharp/blob/f3695d5abbf35e4f0b59ef744e42f664cfb535cb/Gotrue/Client.cs#L200

{"error":"server_error","error_description":"Internal Server Error"}
This is a error, i used other log info but nothing.

This Exception helps:
Console.WriteLine(ex.HelpLink); Console.WriteLine(ex.InnerException); Console.WriteLine(ex.Message); Console.WriteLine(ex.Source);

Also btw I've used that method for the native Sign in with Apple flow but not the OAuth flow, very interesting to doc that flow...

string identityToken = Encoding.UTF8.GetString(System.Text.Encoding.UTF8.GetBytes(GoogleOrAppleIdToken), 0, GoogleOrAppleIdToken.Length);

Well i used your example with little fix for Google, THX to you.

If you attach a debugger it's possible that there is more info in the base response, but maybe not.

If it works for existing user but not a new user not sure. If you create a user via sign in with email for the same address first does that work? Any other logic (eg creating a user profile via trigger) that could be affecting things?

If it's straight up a server challenge might check the server logs for info and/or open a support ticket?

Hey bro thank you soo much i enable the doubletap User Signups Allow new users to sign up and work fine.
I dont know why is disabled.

If you attach a debugger it's possible that there is more info in the base response, but maybe not.

If it works for existing user but not a new user not sure. If you create a user via sign in with email for the same address first does that work? Any other logic (eg creating a user profile via trigger) that could be affecting things?

If it's straight up a server challenge might check the server logs for info and/or open a support ticket?

Hey bro thank yu soo much i enable the doubletap User Signups Allow new users to sign up and work fine.
I dont know why is disabled.
How can create a new documentation for new user? This problem a tried to work on my app one day of work.
P.D: Sorry for my English

Woot! Glad you got it working!

RE: adding docs, easy mode: you can just write up docs in Markdown and post as a public gist and add an issue to add to the repo. Alternatively you can send in a PR if you are feeling fancy.

Woot! Glad you got it working!

RE: adding docs, easy mode: you can just write up docs in Markdown and post as a public gist and add an issue to add to the repo. Alternatively you can send in a PR if you are feeling fancy.

OAuth(Google) + Supabase + Native Android(MAUI, Xamarin Forms, Xamarin Android)

Thank y'all for the work debugging/troubleshooting this! Documentation is now available on the wiki for it here