skip to Main Content

When i try to SignIn with Google google_sign_in: ^6.1.6

I got an error

[GSI_LOGGER-OAUTH2_CLIENT]: Popup timer stopped.
[GSI_LOGGER-TOKEN_CLIENT]: Trying to set gapi client token.
[GSI_LOGGER-TOKEN_CLIENT]: The OAuth token was not passed to gapi.client, since the gapi.client library is not loaded in your page.

This is My Code :

import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_sign_in/google_sign_in.dart';

final authRepositoryProvider = Provider((ref) {
  return AuthRepository(googleSignIn: GoogleSignIn());
});

class AuthRepository {
  final GoogleSignIn _googleSignIn;
  AuthRepository({
    required GoogleSignIn googleSignIn,
  }) : _googleSignIn = googleSignIn;

  void googleSignIn() async {
    try {
      final user = await _googleSignIn.signIn();
      if (user != null) {
        print(user.email);
        print(user.displayName);
      }
    } catch (e) {
      print(e);
    }
  }
}

Error:
enter image description here

Anybody encountered this problem and been able to solve it?

2

Answers


  1. I have used this function recently in my project and it work

    final FirebaseAuth _auth = FirebaseAuth.instance;
      final GoogleSignIn _googleSignIn = GoogleSignIn();
         Future<String?> signInwithGoogle() async {
            try {
              final GoogleSignInAccount? googleSignInAccount =
                  await _googleSignIn.signIn();
              final GoogleSignInAuthentication googleSignInAuthentication =
                  await googleSignInAccount!.authentication;
              final AuthCredential credential = GoogleAuthProvider.credential(
                accessToken: googleSignInAuthentication.accessToken,
                idToken: googleSignInAuthentication.idToken,
              );
              await _auth.signInWithCredential(credential);
            } on FirebaseAuthException catch (e) {
              print(e.message);
              throw e;
            }
          }
    

    for more help follow this blog
    https://petercoding.com/firebase/2021/05/24/using-google-sign-in-with-firebase-in-flutter/

    if you understand Hindi/Urdu language follow this video for latest documentation and method
    https://youtu.be/rt7B4tD67Gw

    Login or Signup to reply.
  2. I see that you are working with Flutter Web.
    Have you done the Web Implementation for google_sign_in package?

    Also, I found a great tutorial for your problem: https://codeontherocks.dev/blog/google-sign-in-flutter/

    He wrote this about the error that you see:

    This code will open the Google Sign In popup and allow the user to select their account. Once again, this process does not return an ID token so it is NOT RECOMMENDED. Further, you may see the following error logged in the console:

    The OAuth token was not passed to gapi.client, since the gapi.client library is not loaded in your page.

    This message can be safely ignored although it should serve as a reminder that you will not have access to the user’s ID token.

    Please check the example repository as well 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search