Open lichengz opened 1 month ago
For android, I don't think you need client ID. It seem google will use bundle ID of the app and figure out by itself
For ios though, it seem you need to update your Info.plist
in xcode project
If you want serverAuthCode or IdToken, there is webClientId in configuration. And you need to create and use credential Id for web page
For android, I don't think you need client ID. It seem google will use bundle ID of the app and figure out by itself For ios though, it seem you need to update your
Info.plist
in xcode project If you want serverAuthCode or IdToken, there is webClientId in configuration. And you need to create and use credential Id for web page
Hi, thank you for you quick response! I'm making an android build. I was using Google Play Games plugin for Unity, which asks me to provide client ID and it works. Now I switched to your port of Google log in plugin, which is for sure amazing. However, I got a No Client ID found error when calling OnGamesSignIn, and I don't remeber I ever provided a client ID.
Thank for reporting. I will take a look
sounds good, thanks!
the original google-signin-unity documention didn't mention anything about providing a clientID for Play Games. however, according to https://github.com/playgameservices/play-games-plugin-for-unity, a clientID is required. so confusing...
2024/06/12 11:45:44.723 13246 13273 Error Unity AndroidJavaException: java.lang.IllegalArgumentException: serverClientId should not be empty
2024/06/12 11:45:44.723 13246 13273 Error Unity java.lang.IllegalArgumentException: serverClientId should not be empty
2024/06/12 11:45:44.723 13246 13273 Error Unity at com.google.android.libraries.identity.googleid.GetGoogleIdOption.
Based on your log, it seem there might be a bug of mine, or q change in behaviour
But it might be success if you have pass webClientId (making a web credential) and set it at GoogleSignInConfiguration.WebClientId
Based on the old document, we still need Google Sign-In configuration file in the project and also my new package might failed to read that, I am currently investigating
As far as I can see, currently now it seem google insist that you need to have both credential for android and web. And you need clientId of web credential to set in the configuration
https://developer.android.com/identity/sign-in/credential-manager-siwg#set-google
Hi I can confirm that my project have both andoird and web client IDs. It works with Google Play Games plugin for Unity So I think now the problem is how to tell google-signin-unity what the android client ID is.
My project don't have anything declare android client ID at all and it work fine just providing web client ID
This is only file exist in my sample project, not even google configuration file needed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Google;
using System.Threading.Tasks;
public class GoogleSignInBehaviour : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod]
static void Config()
{
GoogleSignIn.Configuration = new GoogleSignInConfiguration() {
RequestEmail = true,
RequestProfile = true,
RequestIdToken = true,
RequestAuthCode = true,
WebClientId = "XXXXXXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
#if UNITY_EDITOR || UNITY_STANDALONE
ClientSecret = "XXXXXX-xxxXXXxxxXXXxxx-xxxxXXXXX"
#endif
};
}
[SerializeField]
TMPro.TMP_Text text;
public void SignIn()
{
GoogleSignIn.DefaultInstance.SignIn().ContinueWith((task) => {
var user = task.Result;
text.text = string.Join("\n",new [] {
user.UserId,
user.Email,
user.DisplayName,
user.ImageUrl.AbsoluteUri,
user.IdToken,
user.AuthCode,
});
},TaskScheduler.FromCurrentSynchronizationContext());
}
}
@Thaina Do you have anything set for "Authorized JavaScript Origins" and "Authorized redirect URIs" for the Web App Client ID in the Cloud Dashboard? Because I'm trying to run the script above with just WebClientId but I get this error when I select an account from the popup:
2024/07/16 00:27:44.120 23713 23713 Error Unity onFailure class androidx.credentials.exceptions.GetCredentialCancellationException : [16] Account reauth failed.
I have set localhost and firebase for Authorized js relate setting. Maybe localhost was needed, but I don't think so
Do you have both android and webclientID ? I think it need both
I have resolved the issue - it seems like an Android Client ID has to exist within the same project in the Cloud Dashboard (even though you only use the Web App Client ID). Adding localhost in Authorized redirects URI made it work for the Editor.
Thanks a lot!
Hi,
Could anyone help me find out where to enter a clientID for Play Games log in?
Thanks.