0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FlutterにてFirebaseでGoogleログインする時にGoogleSignInException(code GoogleSignInExceptionCode.clientConfigurationError, serverClientId must be provided on Android, null)

0
Posted at

Flutter × Firebase で Google ログイン時に GoogleSignInException: serverClientId must be provided エラーが出る場合の解決方法

原因

Android 環境で Google ログインを行う際、serverClientId が設定されていないことが原因です。
Flutter アプリはネイティブアプリであっても Google Cloud Console の「Web クライアント」IDserverClientId に渡す必要があります。


解決方法

  1. Google Cloud Console を開く
    https://console.cloud.google.com/apis/credentials

  2. 左上のプロジェクト選択から、エラーが発生している Firebase プロジェクト を選択

  3. OAuth 2.0 クライアント ID の一覧から Web client を開く

    ※Flutter アプリはスマホアプリですが、ここでは Web client が正しいです

  4. 画面右の Additional information から「クライアント ID」をコピー

  5. firebase_options.dartandroidFirebaseOption にある androidClientId に代入

    FirebaseOptions(
      androidClientId: '<コピーしたクライアントID>',
      ...
    )
    

GoogleSignIn.instance.initialize() を呼び出している箇所を以下のように修正

await GoogleSignIn.instance.initialize(
  serverClientId: '<FirebaseOptionのandroidClientId>'
);

参考
https://github.com/flutter/flutter/issues/172073#issuecomment-3067310666

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?