google-signin-unity icon indicating copy to clipboard operation
google-signin-unity copied to clipboard

Recent migration attempt

Open Thaina opened this issue 1 year ago • 25 comments

Since there is deprecation and migration recommendation from signin system

: copied from readme >

https://developer.android.com/identity/sign-in/legacy-gsi-migration https://developers.google.com/identity/sign-in/ios/quick-migration-guide

Thank for ios fix which was cherrypicked from this fork : https://github.com/pillsgood/google-signin-unity

Android was migrated to use CredentialManager and AuthorizationClient since GoogleSignInAccount was deprecated

However, GoogleIdTokenCredential actually not provide numeric unique ID anymore and set email as userId instead, so I have to extract jwt sub value from idToken (which seem like the same id as userId from GoogleSignIn of other platform)

Tested in unity 2021.3.21 and unity 6000.0.4

Add UPM dependency with branch tag https://github.com/Thaina/google-signin-unity.git#newmigration

{
  "dependencies": {
    "com.google.external-dependency-manager": "https://github.com/googlesamples/unity-jar-resolver.git?path=upm",
    "com.google.signin": "https://github.com/Thaina/google-signin-unity.git#newmigration",
}

Thaina avatar Jun 10 '24 11:06 Thaina

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jun 10 '24 11:06 google-cla[bot]

@calumma-robert Do you interest in signing google CLA agreement?

Thaina avatar Jun 10 '24 11:06 Thaina

@Thaina done!

calumma-robert avatar Jun 10 '24 11:06 calumma-robert

Thank you very much

Thaina avatar Jun 10 '24 11:06 Thaina

GoogleSignIn.Configuration ??= new GoogleSignInConfiguration()
{
    WebClientId = Env.GoogleWebClientId,
    RequestIdToken = true,
    UseGameSignIn = false,
    RequestEmail = true,
    HidePopups = true
};

var user = await DefaultInstance.SignInSilentlyAsync();
  1. Dismissing the popup may sometimes prompt the following image

  2. The prompt is always shown, there is no 'silently' sign in. I cant see how to fix this

nixonjoshua98 avatar Jul 12 '24 21:07 nixonjoshua98

@nixonjoshua98 I have push the new fix to allow auto signin for device with multiple account. But I just have found some detailed concern about this case

https://developer.android.com/identity/sign-in/credential-manager-siwg#enable-sign-in https://stackoverflow.com/a/78269657/1260333

As there is mention about criteria to auto signin. Even we have auto signin for the device with multiple account, if there is also more than one account had ever signin to your app, the account selector will still be launched anyway in the same manner you have experienced

The stackoverflow answer above have mention that you might need to revoke access to the app from the account too, and have only one account connect to the app

I have just create google issue for request a feature to specified email hint (as the new identity signin system was not contain API to set a hint anymore). Would you pleased to upvote this issue too?

https://issuetracker.google.com/issues/352864317

Thaina avatar Jul 13 '24 16:07 Thaina

Much love, I've upvoted it. Thanks for the quick responses

nixonjoshua98 avatar Jul 13 '24 17:07 nixonjoshua98

Is there any update on 'silently' sign in ? @Thaina @nixonjoshua98

nivedhKA avatar Jul 23 '24 06:07 nivedhKA

I went with the approach of storing an encrypted token after signing in, which stores your login preference. Let's me skip the Google login popup, and I just send that token to my backend.

nixonjoshua98 avatar Jul 23 '24 09:07 nixonjoshua98

Is there any update on 'silently' sign in ? @Thaina @nixonjoshua98

It should be silent if you have only one account signing in into your app in your device, isn't it?

Thaina avatar Jul 23 '24 10:07 Thaina

Yes, it's working and doesn't open dialog ui of account selecting but still encounter the following error in the logs during a slientlysignin :

NoCredentialException: During begin sign-in, failure response from one tap: 16: User disabled the feature

Upon researching this error, I discovered that it occurs when the Google account's sign-in prompt is disabled. Specifically, if a user has only one account signed in and has disabled the one-tap sign-in feature in their Google account settings, this error is generated. When I enabled the one-tap sign-in for the affected Google account, the error disappeared. However, the account selection dialog appears again.

Steps to Reproduce

  1. Ensure only one Google account is signed into the device.
  2. Disable the one-tap sign-in feature for this Google account in its settings.
  3. Attempt to sign in silently using the app.
  4. Observe the NoCredentialException error in the logs.
  5. Enable the one-tap sign-in feature for the Google account.

rEhN8flk

  1. Attempt to sign in silently again and notice that the account selection dialog appears once more.

nivedhKA avatar Jul 23 '24 10:07 nivedhKA

Based on your step, isn't those expected behaviour? Or are there other behaviour we should have?

Thaina avatar Jul 23 '24 10:07 Thaina

@nivedhKA Where is that setting, i can't seem to find it? I have this exception for a couple of users as well.

nixonjoshua98 avatar Jul 23 '24 11:07 nixonjoshua98

@nivedhKA Where is that setting, i can't seem to find it? I have this exception for a couple of users as well.

In Android Device -> Open Settings -> Find Google Account -> Select Google Account And Select -> Open Manage Account And Search Sign In prompts.

nivedhKA avatar Jul 30 '24 07:07 nivedhKA

@nivedhKA I think I just understand your issue

I think what you trying to do, which is disabling signinprompt, are not given what you expected

What I think it would is revoking the signin of the app from all of your accounts except one, which is difference thing from just disabling signin prompt

I am not testing it yet but maybe this might work

image

Thaina avatar Aug 09 '24 06:08 Thaina

@Thaina Is there a unity package? Or how to build it.

to google And please maintain it as soon as possible.

o-osawa avatar Dec 18 '24 10:12 o-osawa

@Thaina Is there a unity package? Or how to build it.

to google And please maintain it as soon as possible.

I don't know, I don't use unitypackage to the point I already forgot how to made it properly for package

I would like to also dissuade on using unitypackage. Are there any reason you cannot move on to use upm instead?

Thaina avatar Dec 18 '24 10:12 Thaina

Thank you. I was looking for how to use it and didn't know about UPM. I understand that you need to put the git URL into Unity Package Manager. I'll try it.

o-osawa avatar Dec 19 '24 15:12 o-osawa

Is there any update on 'silently' sign in ? @Thaina @nixonjoshua98

even with one account also same popup !!! each time it asking to select account to login !!!

WhatsApp Image 2025-02-14 at 05 42 50_20979830

WhatsApp Image 2025-02-14 at 06 14 42_74aa7928

shiva30122 avatar Feb 14 '25 00:02 shiva30122

@shiva30122 We need more log to investigate

Thaina avatar Feb 14 '25 04:02 Thaina

@Thaina

@shiva30122 We need more log to investigate

             No Log available on silent login() it just popup all accounts !!>............ UNKNOWN 

Doubts ?........

Android Works is IOS will be Easy ?? to make Sign ???

100% iam needed WebClint ID on IOS to get AuthCode is it Possible ? And I also need to create separate IOS Clint ID whare 2 ClientID -> IOS ClientID and IOS ClientID Revers ??..... And how to Use ???

ANY TIPS ?......

Edited :

New to GitHub !... sorry for unwanted message !...

shiva30122 avatar Feb 14 '25 06:02 shiva30122

@shiva30122 We need more log to investigate

and it surely will be some log around the silentsignin especially before popup occur

You need to understand the engineering process about how to debug your system on device. Or else no one can help you. Don't just throw random message around chaotically

About 2 clientID. You can write #if directive per platform by yourself

Thaina avatar Feb 14 '25 06:02 Thaina

New to GitHub !... sorry for unwanted message !...

@Thaina

and i tried using only one google account on my mobile then also popup thins select account for silent login() !.

Debugging is not showing any error and it simply login me both normal Sign() or Silently-Login() .

my problem is Silent Login() Issue when user already Login !..... and i tried with code also for making silent login on Star() method not working !.

any solution !??? or Still Development ?... or i need to implement anything manually ??...

now my problem is clear !?..

Unity.package --> Silently-Login_Notworking.zip iam using Unity 6 .

but in last iam getting Debug.Log("ServerAuthCode : " + authCode) ; !.. Working bit only silent login() issue !.

Refer My Video --> https://youtu.be/6DQGnQv-GL0

shiva30122 avatar Feb 14 '25 11:02 shiva30122

@shiva30122 There are 3 things I can think of 1 - you may not set HidePopups to true 2- See this comment > https://github.com/googlesamples/google-signin-unity/pull/256#issuecomment-2257629517 3 - You have already sign in with google with multiple account in that device. This was one problem of new version of Google credential manager and I can't do anything about it. It will insist to have popup because it was unsure which account you really want to use

Thaina avatar Feb 14 '25 14:02 Thaina

@shiva30122 Please investigate the criteria mention in this link to determine if your device's setting are not met any of it

https://developer.android.com/identity/sign-in/credential-manager-siwg#enable-sign-in

Thaina avatar Feb 14 '25 15:02 Thaina

@Thaina I'm testing your branch in my app. And I'm facing issue with discrepancies in GoogleSignInStatusCode between platforms. When I open Google Sign-In dialog in the iOS app and instead of continuing the sign-in process I press "Cancel" on account selection popup, I get GoogleSignInStatusCode with value 2 that is treated as SERVICE_VERSION_UPDATE_REQUIRED status by plugin. Seems like status codes are just different now between iOS and Android. iOS still preserves older status code with status code 2 being GoogleSignInStatusCode.Cancel. Is that something you know about and willing to fix in the branch?

rysenko avatar Jun 25 '25 14:06 rysenko

I would take a look and try to update the package in near future. There is many things I would like to update too. But currently now very busy though, pardon me that it may not be so soon

Thaina avatar Jun 25 '25 14:06 Thaina

Hello,

I'm currently integrating Google Sign-In in my Unity Android project. While checking library alignment for 16 KB page size using the recommended tooling, I found that the native-googlesignin.so file is not aligned to 16 KB, unlike the other .so libraries in the project.

Alignment Check Result:

Image

Because of this misalignment, I am getting below warning on Google Play Console.

Image

Environment details:

Unity Version: 6000.0.58f2 Google Sign-In Version: 1.0.4 Platform: Android

Milan1660 avatar Oct 14 '25 11:10 Milan1660

Are you really using my branch with upm?

Thaina avatar Oct 14 '25 11:10 Thaina

Are you really using my branch with upm?

Yes, I am using your branch with UPM

Milan1660 avatar Oct 14 '25 11:10 Milan1660