Back

[SOLVED] Auth flutter

  • 0
  • Users
  • Flutter
  • Accounts
Dreix
7 Aug, 2023, 19:37

And how could I do it because if eh replaced the correct id and key of Google cosola and I realize that in appwrite if you register but the app does not log in I think I have an error in my code I am in flutter.

TL;DR
The user is asking if it's possible to use login with Google natively or only through the web. There is no clear solution provided in the thread.
Drake
7 Aug, 2023, 20:25

Sorry I don't quite understand you

Dreix
7 Aug, 2023, 20:36

I mean that appwrite if the user is saved, but in the app it does not receive the credentials

Drake
7 Aug, 2023, 21:19

do you mean you're not redirected back into the app?

Dreix
7 Aug, 2023, 23:18

If it redirects me but does not validate the credentials, an error appears when starting with Google.

Drake
7 Aug, 2023, 23:21

sprry i don't understand

Drake
7 Aug, 2023, 23:21

maybe you can share a recording of what's going wrong?

Dreix
8 Aug, 2023, 00:34
Drake
8 Aug, 2023, 00:46

what's your updated code including _updateAuthStatus()? Please make sure to format the code using 3 back ticks.

Drake
8 Aug, 2023, 00:48

please also share your logs because the screen recording doesn't show the output of

TypeScript
      if (e is AppwriteException) {
        print('Error al iniciar sesión con OAuth:');
        print('Mensaje: ${e.message}');
        print('Código: ${e.code}');
        print('Tipo: ${e.type}');
      } else {
        print('Excepción no reconocida:');
        print(e);
      }
Dreix
9 Aug, 2023, 14:36

I/flutter ( 9414): Error al iniciar sesión con OAuth: I/flutter ( 9414): Mensaje: Invalid OAuth2 Response. Key and Secret not available. I/flutter ( 9414): Código: 500 I/flutter ( 9414): Tipo: null I/flutter ( 9414): Inicio de sesión con Google fallido

safwan
9 Aug, 2023, 14:46

What is the code in _updateAuthStatus()?

Dreix
9 Aug, 2023, 14:51

Stream<bool> isAuthenticated() { _updateAuthStatus(); return _authController.stream; }

void _updateAuthStatus() async { bool isAuthenticated = await _checkAuthenticated(); _authController.add(isAuthenticated); }

safwan
9 Aug, 2023, 14:54

Okay and what's inside _checkAuthenticated()

Dreix
9 Aug, 2023, 14:54

With email and password the login works correctly, but with Google I don't want appwrite if the name, email and verification are registered normally but it doesn't log in.

Dreix
9 Aug, 2023, 14:55

Future<bool> _checkAuthenticated() async { try { await account.get(); return true; } catch (e) { print(e); return false; } }

safwan
9 Aug, 2023, 15:20

Did you remove the success and failure fields?

Dreix
9 Aug, 2023, 15:25

Enough already and apparently if you log in but the black screen stays, I close it and turn it on, it opens and validates that if you log in, it takes me home. But I don't know how to fix the black screen

Dreix
9 Aug, 2023, 15:26

Future<bool> loginWithOAuth(String provider) async { try { final session = await account.createOAuth2Session(provider: provider); _updateAuthStatus(); return true; } catch (e) { if (e is AppwriteException) { print('Error al iniciar sesión con OAuth:'); print('Mensaje: ${e.message}'); print('Código: ${e.code}'); print('Tipo: ${e.type}'); } else { print('Excepción no reconocida:'); print(e); } return false; } }

Drake
9 Aug, 2023, 16:29

looks like your oauth2 failed for some reason...

Drake
9 Aug, 2023, 16:29

Please make sure to use 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

Drake
9 Aug, 2023, 16:31

on your computer, browse to https://cloud.appwrite.io/v1/account/sessions/oauth2/google?project=<your project id> and try to log in

Dreix
9 Aug, 2023, 23:02

already solved. I have another question, is it possible to use the login with google natively or only through the web?

D5
9 Aug, 2023, 23:03

Only through web

D5
9 Aug, 2023, 23:03

[SOLVED] Auth flutter

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more