unityでFIRE Baseを用いてGoogle認証したい

実現したいこと

unityでFIRE Baseを用いてGoogle認証したいが、エラーが出る。認証できない。
認証できるようにしたい。

前提

=環境=
Mac mini 2023 M2
Mac OS Sonoma 14.2.1

Unity 2022.3.16f1 Silicon LTS

firebase_unity_sdk_11.6.0
FirebaseAuth.unitypackage

GoogleService-Info.plistはassetフォルダに存在
Google と メール、パスワード認証を有効済

発生している問題・エラーメッセージ

=エラー内容= SignInWithGoogle encountered an error: System.AggregateException: One or more errors occurred. (An internal error has occurred.) ---> Firebase.FirebaseException: An internal error has occurred. at Firebase.Auth.FirebaseAuth.SignInWithCredentialAsync (Firebase.Auth.Credential credential) [0x00032] in /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/auth/swig/Firebase.Auth_fixed.cs:4257 --- End of inner exception stack trace --- ---> (Inner Exception #0) Firebase.FirebaseException: An internal error has occurred. at Firebase.Auth.FirebaseAuth.SignInWithCredentialAsync (Firebase.Auth.Credential credential) [0x00032] in /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/auth/swig/Firebase.Auth_fixed.cs:4257 <--- UnityEngine.Debug:LogError (object) FirebaseAuthManager/<>c:<SignInWithGoogle>b__3_0 (System.Threading.Tasks.Task`1<Firebase.Auth.FirebaseUser>) (at Assets/Scenes/first/script/FirebaseAuthManager.cs:35) System.Threading._ThreadPoolWaitCallback:PerformWaitCallback () GCPでログを見ると、次のエラーが出てましたが。 今は出ていません。 SetIamPolicy Exception calling IAM: There were concurrent policy changes. Please retry the whole read-modify-write with exponential backoff.

該当のソースコード

C#

1using System;2using System.Threading.Tasks;3using Firebase;4using Firebase.Auth;5using UnityEngine;6using UnityEngine.SceneManagement;7 8public class GoogleAuth : MonoBehaviour 9{10 private FirebaseAuth auth;11 12 void Start()13 {14 InitializeFirebase();15 }16 17 // Firebaseの初期化18 private void InitializeFirebase()19 {20 FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>21 {22 var dependencyStatus = task.Result;23 if (dependencyStatus == DependencyStatus.Available)24 {25 // Firebaseの初期化26 auth = FirebaseAuth.DefaultInstance;27 Debug.Log("Firebase is ready.");28 }29 else30 {31 Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}");32 }33 });34 }35 36 // Google認証の実装37 public void SignInWithGoogle()38 {39 auth.SignInWithCredentialAsync(GoogleAuthProvider.GetCredential(null, null)).ContinueWith(task =>40 {41 if (task.IsCanceled)42 {43 Debug.LogError("SignInWithGoogle was canceled.");44 return;45 }46 if (task.IsFaulted)47 {48 Debug.LogError($"SignInWithGoogle encountered an error: {task.Exception}");49 return;50 }51 52 FirebaseUser newUser = task.Result;53 Debug.Log($"User signed in successfully: {newUser.DisplayName} ({newUser.UserId})");54 55 // シーン遷移56 SceneManager.LoadScene("MainScene");57 });58 }59 60 // ユーザーがGoogleサインインボタンをクリックしたときの処理61 public void OnGoogleSignInButtonClicked()62 {63 SignInWithGoogle();64 }65}

コメントを投稿

0 コメント