skip to Main Content
  1. I am NOT using Firebase
  2. I am still in early developer phase, so not even tried to publish at all on Play Store
  3. My goal is to ask user to login to allow to upload photos to user’s google drive.
  4. This question is not duplicated due the fact that almost 100% of questions/answers are related to Firebase.

My code is the following.

Please note: I ask user to login to allow to upload photos to user’s Google drive.

import 'dart:developer';

import 'package:google_sign_in/google_sign_in.dart';

GoogleSignIn _googleSignIn = GoogleSignIn(
  scopes: <String>[
    'https://www.googleapis.com/auth/drive.file',
  ],
);

class AuthManager {
  static Future<GoogleSignInAccount?> signIn() async {
    try {
      final account = await _googleSignIn.signIn();
      log('account: ${account?.toString()}', name: 'AuthManager');
      return account;
    } catch (error) {
      log('signIn error:', name: 'AuthManager');
      log(error.toString(), name: 'AuthManager');
      return null;
    }
  }

  static Future<void> signOut() async {
    try {
      _googleSignIn.disconnect();
    } catch (error) {
      print(error);
    }
  }

  static Future<bool> isSignedIn() async {
    return _googleSignIn.isSignedIn();
  }
}

The error logged is

[AuthManager] signIn error:
[AuthManager] PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)

I know that error number 10 is ‘developer error’, due to something misconfigured.

But what!!?!?

WHAT I HAVE ALREADY TRIED

  1. I generated a key store for my app

    My app is being signed in debug mode.

    Nothing changes, same exception

  2. I created a oauth client for my app using package name and sha1 read from the generated keystore

    I do not know how will Goggle login connect my flutter app with this oauth credential

    Nothing changes, same exception number 10

2

Answers


  1. Implemented similar thing, you need to generate keystore. Follow this guide for detailed answer. I suggest you to follow Android Studio Key Generation Steps.

    Login or Signup to reply.
  2. Try the following (ignore the steps that you have already done)

    1. Open API & Services Credentials
    2. Click on Create Credentials
    3. Then in dropdown click on OAuth Client ID
    4. Application Type: Android
    5. Name: Whatever like Android Dev
    6. Package name: com.yourpackagename
    7. SHA-1 certificate fingerprint: your_key. To generate go to root/android folder and run ./gradlew signingReport
    8. Click on create
    9. Test
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search