Giter VIP home page Giter VIP logo

Comments (70)

Disturbing avatar Disturbing commented on June 13, 2024

Agreed! I definitely need this as well.

Please implement auth token to be exposed to unity:

http://developer.android.com/google/play-services/auth.html

Thanks in advance!

from play-games-plugin-for-unity.

MAW016 avatar MAW016 commented on June 13, 2024

Agreed as well!

from play-games-plugin-for-unity.

makeshiftwings avatar makeshiftwings commented on June 13, 2024

Can someone please, please (PLEASE) offer some advice on how to access the auth token? Please?

from play-games-plugin-for-unity.

repel avatar repel commented on June 13, 2024

Pretty sure that isn't allowed per Google.

The Auth token would be useless because of the device which obtained it. To do what you want you must implement oauth2 on the Web server, request a server Api key then apply it to server. Make sure you server code request offline permissions for the user. Then setupa mysql server db to cache the token and then the refresh token, with that you can get some general info about the user to put in the database, like the email address which you could then cross reference from your Android appm to grant access into your website. Finally, within your application use a webview that doesn't leave your unity activity to display the Google login button on your sight with the proper redirects. Then close webview, and start having fun.

Atleast it how I did it. HopeThat helps

from play-games-plugin-for-unity.

dgalpin avatar dgalpin commented on June 13, 2024

You technically can get the token through the Android GoogleAuthUtil if you
really needed it, but you'd have to be careful about expiry, and you'd want
to make sure that the scopes requested matched. You'd also have to add the
GET_ACCOUNTS permission.

  • D

On Tue, Jun 10, 2014 at 8:52 PM, repel [email protected] wrote:

Pretty sure that isn't allowed per Google.

The Auth token would be useless because of the device which obtained it.
To do what you want you must implement oauth2 on the Web server, request a
server Api key then apply it to server. Make sure you server code request
offline permissions for the user. Then setupa mysql server db to cache the
token and then the refresh token, with that you can get some general info
about the user to put in the database, like the email address which you
could then cross reference from your Android appm to grant access into your
website. Finally, within your application use a webview that doesn't leave
your unity activity to display the Google login button on your sight with
the proper redirects. Then close webview, and start having fun.

Atleast it how I did it. HopeThat helps


Reply to this email directly or view it on GitHub
#10 (comment)
.

from play-games-plugin-for-unity.

repel avatar repel commented on June 13, 2024

dgalpin, I believe their intentions is to incorporate and consume that auth token into a outside website. To do so according would require the infrastructure that I spoke of above to be in place to handle token refreshes, and all necessary access grants in place for both the android app and the web components. Yes, the token is available but pretty useless on its own.

from play-games-plugin-for-unity.

metalize avatar metalize commented on June 13, 2024

I also need the OAuth token and I'm implementing a system quite similar to your description, @repel. I have all the infrastructure already, I just need the OAuth token from within Unity. Is there any way to get it from the plugin or will I need to write native code to do it? @dgalpin, is GoogleAuthUtil available from within the plugin? A grep through the source did not show any results.

from play-games-plugin-for-unity.

tristan-fgol avatar tristan-fgol commented on June 13, 2024

+1 for AuthToken for server side authentication

from play-games-plugin-for-unity.

samtstern avatar samtstern commented on June 13, 2024

If you want to use the auth token from your Android/iOS Unity app on your web server (or anywhere off the original device) this is not a good idea. You shouldn't send auth tokens around, they are meant to be used by the client to which they were issued.

If you want to authorize your server to perform actions with Google APIs, you'll want to request a server auth code which your server can exchange for an offline access refresh token. The documentation for this process is here: https://developers.google.com/+/web/signin/server-side-flow

As others have mentioned on this thread, you'll have to go outside the Unity plugin (GoogleAuthUtil, etc) to make this work for now.

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

tracking internally to expose client auth as 19126504

from play-games-plugin-for-unity.

boudinov avatar boudinov commented on June 13, 2024

Need that too please.

from play-games-plugin-for-unity.

albertvaka avatar albertvaka commented on June 13, 2024

+1 🙆‍♀️

from play-games-plugin-for-unity.

boudinov avatar boudinov commented on June 13, 2024

Found a way to get token with the Doge build (ver >= 0.9.10).
First a problem is that that GoogleApiClient that is created internally in the C++ library, does not request Plus API.
That client is obtained using (but we don't need it):
JavaUtils.JavaObjectFromPointer(GooglePlayGames.Native.Cwrapper.InternalHooks.InternalHooks_GetApiClient(services.AsHandle()))

We need the client to request Plus api, because that is how we get the current Plus account (Plus.ApiAccount...). So we build a new client, and get the token as described in #222

This new code is part of NativeClient class. The code while(!client.Call("isConnected")...sleep() should be run on another thread or in a coroutine, so UI thread is not get blocked until our new client is connected.

        private AndroidJavaObject GetApiClient(GameServices services) {
                    //return JavaUtils.JavaObjectFromPointer(GooglePlayGames.Native.Cwrapper.InternalHooks.InternalHooks_GetApiClient(services.AsHandle()));
                    using (var currentActivity = GetActivity()) {
                            using (AndroidJavaClass jc_plus = new AndroidJavaClass("com.google.android.gms.plus.Plus")) {
                                using (AndroidJavaObject jc_builder = new AndroidJavaObject("com.google.android.gms.common.api.GoogleApiClient$Builder",currentActivity)) {
                                            jc_builder.Call<AndroidJavaObject> ("addApi", jc_plus.GetStatic<AndroidJavaObject>("API"));
                                            jc_builder.Call<AndroidJavaObject> ("addScope", jc_plus.GetStatic<AndroidJavaObject>("SCOPE_PLUS_LOGIN"));
                                            AndroidJavaObject client = jc_builder.Call<AndroidJavaObject> ("build");
                                            client.Call ("connect");
                                            while(!client.Call<bool>("isConnected"))
                                            {
                                                    System.Threading.Thread.Sleep(100);
                                            }
                                            return client;
                                }
                            }
                    }
            }

            private string RetrieveUserEmail() {
                    string email;
                    using (AndroidJavaClass jc_plus = new AndroidJavaClass("com.google.android.gms.plus.Plus")) {
                            using (AndroidJavaObject jo_plusAccountApi = jc_plus.GetStatic<AndroidJavaObject>("AccountApi")) {
                                    Debug.Log("jo_plusAccountApi: " + (jo_plusAccountApi == null ? "NULL" : jo_plusAccountApi.ToString()));
                                    using (var apiClient = GetApiClient(mServices)) {
                                            Debug.Log("apiClient: " + (apiClient == null ? "NULL" : apiClient.ToString()));
                                            email  = jo_plusAccountApi.Call<string>("getAccountName", apiClient);
                                            Logger.d("Player email: " + email);
                                    }
                            }
                    }
                    return email;
            }

            public string GetToken() {
                    string token = null;
                    Debug.Log("Before RetrieveUserEmail");
                    string email = RetrieveUserEmail() ?? "NULL";
                    Debug.Log("After RetrieveUserEmail email: " + email);
                    string scope = "audience:server:client_id:" + "101626759741-kc5sdafasdfsdf9j1aek9bfgfou3oom.apps.googleusercontent.com";//CLIENT_ID;
                    using (AndroidJavaClass jc_unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
                           jc_gau = new AndroidJavaClass("com.google.android.gms.auth.GoogleAuthUtil")) {
                            using(AndroidJavaObject jo_Activity = jc_unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) {
                                    token = jc_gau.CallStatic<string>("getToken", jo_Activity, email, scope);
                            }
                    }
                    Debug.Log("Token " + token);
                    return token;
            }

This gets an ID Token (Java web token). A normal access token can be obtained by replacing scope (audience:server:client_id:....) with something like(https://www.googleapis.com/auth/plus.login)

A side note, can some scholarly guy tell is if we are in a very wrong direction, trying to get an access token this way, and that is why there is no built-in support for this in the Unity Plugin?

from play-games-plugin-for-unity.

Boogscraft avatar Boogscraft commented on June 13, 2024

Thank you boudinov, the ID token is exactly what I need (and I suspect most people here) to implement this flow: http://android-developers.blogspot.com/2013/01/verifying-back-end-calls-from-android.html

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

@boudinov - at first glance this looks great! Do you think you can create a pull request so it can be looked at a little more closely and then become part of the plugin?

from play-games-plugin-for-unity.

zindonx avatar zindonx commented on June 13, 2024

i make all the stuff, that is described here and always get AndroidJavaException: com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission.

Any suggestion?

Best regards.

from play-games-plugin-for-unity.

JohnTube avatar JohnTube commented on June 13, 2024

@zindonx

Comments regarding this Exception thrown by GoogleAuthUtil.getToken

catch (UserRecoverableAuthException e) {
  // Requesting an authorization code will always throw
  // UserRecoverableAuthException on the first call to GoogleAuthUtil.getToken
  // because the user must consent to offline access to their data.  After
  // consent is granted control is returned to your activity in onActivityResult
  // and the second call to GoogleAuthUtil.getToken will succeed.
  startActivityForResult(e.getIntent(), AUTH_CODE_REQUEST_CODE);
  return;
} 

source
more details here

from play-games-plugin-for-unity.

ccthien avatar ccthien commented on June 13, 2024

Do we have any update?
Anyone know the reason why this is not implemented until now?

from play-games-plugin-for-unity.

ZenithCode avatar ZenithCode commented on June 13, 2024

@claywilkinson @ccthien - This would be really nice to have for us too. An ETA would be nice! 👍

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

So, is there any working method of obtaining google login token on client side? Anyone? bump

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

@claywilkinson Please give us an update on this, as it would be a great improvement on what we need to do. While what @boudinov has done is great (and it really is), that's Android only, and definitely "feels" a little hacky, especially the way some of the grabbing and building the client is done, especially if that part (apparently) is already done.

With Google supporting the whole OpenID single-signon stance, and how widely it's used everywhere, I'm still at odds how it wasn't intrinsically part of the whole project, but now the you started talking about this way back in January 23rd, but while there have been recent commits, you haven't responded to this thread since 5th February!

C'mon guys, it really doesn't seem like it should be that big a deal and if you support devs getting access tokens on Android and iOS native, we should be able to get them via SDKs like this.

from play-games-plugin-for-unity.

spacetraveller avatar spacetraveller commented on June 13, 2024

What's the go with this ? This is seriously needed and is a huge block.

What if we need to do API calls that are outside of the PGS plugin ? It's impossible. I don't like being tied in, and this is making it necessary to use third party apps that Google does not recommend. Catch-22... Please Google, fix it!

from play-games-plugin-for-unity.

ccthien avatar ccthien commented on June 13, 2024

Make your own java plugin (like people above already mentioned)... or I have permission to contribute on this source.

from play-games-plugin-for-unity.

spacetraveller avatar spacetraveller commented on June 13, 2024

ccthien that is not a good solution. Google should implement this feature that is the reason for this issue, that is a very roundabout, hacky sort of way and who knows how long before that breaks.

from play-games-plugin-for-unity.

ccthien avatar ccthien commented on June 13, 2024

It is not a hack way. It is what we done on Java, with official play-game-services.jar lib (that they did not implement on this).

from play-games-plugin-for-unity.

tristan-fgol avatar tristan-fgol commented on June 13, 2024

I really need this for both Android and iOS the example provided @boudinov is great for android and we have forked and taken advantage of that but I really need a cross platform way of doing this! Unless someone else has an iOS example as well?

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

@ccthien it is a hack, because it's not in the main repository, nor fully tested by the official providers (Google). It's also, as @tristan-fgol has said, not cross platform as in iOS,

- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
                   error: (NSError *) error
{
    NSLog(@"Received id_token %@ and email %@",
          [auth.parameters objectForKey:@"id_token"],
          [auth.parameters objectForKey:@"email"]);
}

You can only have access to the token in the Authentication flow after a successful login.

Not fully tested, not in the repository, not a full implementation. A hack by any other name.

from play-games-plugin-for-unity.

ccthien avatar ccthien commented on June 13, 2024

Hack & official is difference on who made it.
I made some apps that users usually reported that it is better than official one (even if the official one is free and mine is paid).

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

Bump!
Does anyone know an effective "workaround" how to get an user's google play acces token for that specific app from a frontend (for backend user check towars google again) on both iOS and Android platforms?

Thanks in advance guys!

from play-games-plugin-for-unity.

spacetraveller avatar spacetraveller commented on June 13, 2024

Maybe somebody with a bit of time could write a simple plugin to get this data out of the GPG plugin? (If you're keen, how about creating a repo in github for it?) As it doesn't appear GPGS are going to update their plugin anytime soon with our requests?

Another thing that is very much missing is being able to obtain a registration ID for the app on the Android device - this is necessary for push notifications if you are interfacing with a third party server or your own server.

from play-games-plugin-for-unity.

JurjenBiewenga avatar JurjenBiewenga commented on June 13, 2024

+1

from play-games-plugin-for-unity.

bursaar avatar bursaar commented on June 13, 2024

+1, this'd be a lifesaver!

from play-games-plugin-for-unity.

daveor2112 avatar daveor2112 commented on June 13, 2024

+1 would be great

from play-games-plugin-for-unity.

CormacM avatar CormacM commented on June 13, 2024

+1 this would be really useful

from play-games-plugin-for-unity.

ShaneOBrien avatar ShaneOBrien commented on June 13, 2024

+1 would make life easier

from play-games-plugin-for-unity.

podonne5 avatar podonne5 commented on June 13, 2024

+1 a necessity for our game

from play-games-plugin-for-unity.

halloranjohn avatar halloranjohn commented on June 13, 2024

+1 please add this.

from play-games-plugin-for-unity.

Richief88 avatar Richief88 commented on June 13, 2024

+1 this is what we need to happen!

from play-games-plugin-for-unity.

AuctrixAdmin avatar AuctrixAdmin commented on June 13, 2024

+1 for this. Please implement.

from play-games-plugin-for-unity.

lnobad avatar lnobad commented on June 13, 2024

+1, please add this.

from play-games-plugin-for-unity.

VladimirKuznetsov avatar VladimirKuznetsov commented on June 13, 2024

+1

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

awesome community participation! clearly this is the top priority! :)

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

Hey Clayton, after seeing this thread, http://forum.unity3d.com/threads/google-play-games-login-guide.320187/ on the Unity forum a few days ago, I started poking around with this again and learned that idToken is now exposed from the GPPSignIn singleton on iOS. Because of this, it's as easy as anything to now get the access token, it's not just available to you during the login flow any more. That definitely wasn't around when this thread started, but 100% is now.

With that, I actually went through creating a pull request implementing that, bringing the WebView in from that thread as well (because some apps were getting rejected from it), and the Android GetToken posted in this thread. Will have a pull request ready for you to hopefully review today, as well as a patch for anyone who may want to just apply it to their project.

Thanks for getting back to us on this, though. The biggest frustration was that the services offered in this plugin really are awesome, but then being unable to use this and them because of just this issue.

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

And there we go, pull request is in for you @claywilkinson, #641

And for anyone who wants this, but don't want to wait for the merge & creation of the .unitypackage, here's a patchfile, https://gist.github.com/seaders/9786b9372023af87b1c3#file-tokenpatch-patch which, after installing the 0.9.21 .unitypackage, you can apply simply with git tokenPatch.patch in the root directory of your project.

Happy access tokening!

from play-games-plugin-for-unity.

JohnTube avatar JohnTube commented on June 13, 2024

@seaders thanks for your efforts. I just want to check if your changes are "officially" done and live. And I have also noticed that you used @boudinov code snippet above to get token for Android but you kept it as is without moving the while(!client.Call("isConnected")...sleep() block to a separate background thread to avoid blocking the main UI thread ! This was a recommendation of the original author of the code. So is it safe this way ?

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

@claywilkinson has merged it into the official repo, so it's in there, under source/PluginDev and he's said he'll publish the .unitypackage after he gets a few other things in. As for that suggestion, all calls that may use GetApiClient (it's private) are wrapped with if (!this.IsAuthenticated()), SixMinute@9497353.

I'm going to assume that this will get redesigned, exposing more of the native builder options maybe, when they get a chance (I think a new big-ish release may be coming in September), but for the moment, you can't add the api and scope any other way, kinda. Ensuring that there's already a client that is connected basically means there's nearly no chance of it locking up, unless you enter some sort of weird edge condition.

It's not perfect, and will get better, I know that, but for the moment, if not being able to get the access token was a blocker, it no longer has to be.

Also, on the blocking nature of the call, you are in control of how you get that, so in your code, you could choose to put it behind a Coroutine if you're worried, but I honestly don't think it's that necessary.

from play-games-plugin-for-unity.

JohnTube avatar JohnTube commented on June 13, 2024

@seaders thanks for the clarifications. I think that I will keep using my own Google+ Unity plugin available here as a 3rd party plugin (see Readme).

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

Do you have any rough estimate when the .unitypackage will be released with the auth token implementation?

Thanks a bunch for this update @seaders!
/dances

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

Added this afternoon - if you pull the latest unitypackage it is there.

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

@claywilkinson thank you!

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

Awesome work, @claywilkinson! This, honest to God, is such a relief for us to be able to have the fully legit plugin in. Thanks so much again (closing this thread will be a pleasure, I'd say :P ).

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

I've encountered some issues with 0.9.21 with the updated token support.
Manually cleaned the old version of the plugin (0.9.20) and installed the 0.9.21.

ERROR: first when i try to setup the android it says it's missing "template-GameInfo.txt"
ERROR: two errors appear in unity when trying to compile:

Assets/GooglePlayGames/Platforms/Native/NativeClient.cs(378,26): error CS0117: `GooglePlayGames.GameInfo' does not contain a definition for `WebClientIdInitialized'
Assets/GooglePlayGames/Platforms/Native/NativeClient.cs(386,68): error CS0117: `GooglePlayGames.GameInfo' does not contain a definition for `WebClientId'

(RESOLVED - get latest .unity file)

UPDATE:
Login & token from Android working perfectly.

You can get the token and e-mail by calling:

string email = PlayGamesPlatform.Instance.GetUserEmail();
string accessToken = PlayGamesPlatform.Instance.GetAccessToken();

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

Thanks for the feedback. Looks like I missed a couple files. I'll rebuild the unitypackage today. The corrected GameInfo.cs can be copied from https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/source/PluginDev/Assets/GooglePlayGames/GameInfo.cs

The Template is at https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/source/PluginDev/Assets/GooglePlayGames/Editor/template-GameInfo.txt

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

@claywilkinson While AccessToken works I'm having difficulties accessing the idToken via:
string accessToken = PlayGamesPlatform.Instance.GetIdToken();
After user login it just hangs.

Android log:

08-04 17:16:25.135: D/GamesUnitySDK(26847): Performing Android initialization of the GPG SDK
08-04 17:16:25.405: E/GamesNativeSDK(26847): Exception in dalvik/system/DexClassLoader.loadClass: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.NativeSdkEntryPoints" on path: /data/data/com.aarace.free/app_.gpg.classloader/de80b70ed0da0dfe988a41fa560612ee.jar.
08-04 17:16:25.430: I/GamesNativeSDK(26847): Auth operation started: SIGN IN
08-04 17:16:25.430: I/GamesNativeSDK(26847): Connecting to Google Play...
08-04 17:16:25.735: V/AuthAccountOperation(9516): offline access is not requested
08-04 17:16:25.735: V/BaseAuthAsyncOperation(9516): All scopes had been granted in the past, skip access token fetching
08-04 17:16:25.780: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 17:16:25.900: V/GamesNativeSDK(26847): Play Games callback indicates connection.
08-04 17:16:25.925: I/GamesNativeSDK(26847): Successfully connected to Google Play.
08-04 17:16:26.120: I/Unity(26847): Login was successful!
08-04 17:16:26.160: I/Unity(26847): jo_plusAccountApi: UnityEngine.AndroidJavaObject
08-04 17:16:26.165: I/Unity(26847): Calling GetApiClient....
08-04 17:16:26.280: V/AuthAccountOperation(9516): offline access is not requested
08-04 17:16:26.310: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 17:16:26.455: I/Unity(26847): Done GetApiClient is UnityEngine.AndroidJavaObject
08-04 17:16:26.455: I/Unity(26847): apiClient: UnityEngine.AndroidJavaObject
08-04 17:16:26.460: I/Unity(26847): GOOGLE EMAIL: [email protected]
08-04 17:16:26.465: I/Unity(26847): jo_plusAccountApi: UnityEngine.AndroidJavaObject
08-04 17:16:26.465: I/Unity(26847): Calling GetApiClient....
08-04 17:16:26.485: V/AuthAccountOperation(9516): offline access is not requested
08-04 17:16:26.485: V/BaseAuthAsyncOperation(9516): All scopes had been granted in the past, skip access token fetching
08-04 17:16:26.525: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 17:16:26.570: I/Unity(26847): Done GetApiClient is UnityEngine.AndroidJavaObject
08-04 17:16:26.570: I/Unity(26847): apiClient: UnityEngine.AndroidJavaObject
08-04 17:16:26.640: I/Unity(26847): Before GetEmail
08-04 17:16:26.640: I/Unity(26847): jo_plusAccountApi: UnityEngine.AndroidJavaObject
08-04 17:16:26.640: I/Unity(26847): Calling GetApiClient....
08-04 17:16:26.680: V/AuthAccountOperation(9516): offline access is not requested
08-04 17:16:26.680: V/BaseAuthAsyncOperation(9516): All scopes had been granted in the past, skip access token fetching
08-04 17:16:26.740: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 17:16:26.750: I/Unity(26847): Done GetApiClient is UnityEngine.AndroidJavaObject
08-04 17:16:26.750: I/Unity(26847): apiClient: UnityEngine.AndroidJavaObject
08-04 17:16:26.755: I/Unity(26847): After GetEmail email: [email protected]
08-04 17:16:26.835: I/GLSUser(2880): [GLSUser] getTokenFromGoogle [account: <ELLIDED:5906>, callingPkg: com.aarace.free, service: audience:server:client_id:434824177801-q5p0394959fm1j40jj8s6o3t7451h3nes.apps.googleusercontent.com
08-04 17:16:27.750: I/GLSUser(2880): [GLSUser] getAuthtoken(<ELLIDED:5906>, audience:server:client_id:434824177801-q5p039959fm1j40jj8s6o3t7451h3nes.apps.googleusercontent.com) -> status: UNKNOWN)
08-04 17:16:27.750: I/GLSUser(2880): [GLSUser] Extracting token using key: Auth
08-04 17:16:27.750: W/GLSActivity(2880): gms.StatusHelper Status from wire: INVALID_AUDIENCE status: null
08-04 17:16:27.870: I/Unity(26847): AndroidJavaException: com.google.android.gms.auth.GoogleAuthException: Unknown
08-04 17:16:27.870: I/Unity(26847):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at UnityEngine.AndroidJNISafe.CallStaticStringMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at UnityEngine.AndroidJavaObject._CallStatic[String] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at UnityEngine.AndroidJavaObject.CallStatic[String] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at GooglePlayGames.Native.NativeClient.GetIdToken () [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at GooglePlayGames.PlayGamesPlatform.GetIdToken () [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at GooglePlusManager.DoServerLoginWithGooglePlus () [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at GooglePlusManager.OnAuthenticate (Boolean success) [0x00000] in <filename unknown>:0 
08-04 17:16:27.870: I/Unity(26847):   at GooglePlayGames.Native.NativeClient+<InvokeCallbackOnGameThread>c__Ano

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

This line gms.StatusHelper Status from wire: INVALID_AUDIENCE status: null means you have not configured the web app client ID in the setup dialog. The steps are:

  1. On the Play Console, select your game and make sure you have a linked app which is the type "Web".
  2. copy the client id from the web app and paste it into the web client Id field in the setup dialog.

Also make sure you update the two files that need to be patched (GameInfo.cs and template-GameInfo.txt)

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

I've already set the web app client ID. Now I've set the client id again and I have the same issue with both updated gameinfo files (+NativeClient.cs:378,386 method name fixes).

When I try to get IDToken only, it hangs with the above log.

When I try to get AccessToken only, login works and I get the access token.
This is the log I get with the same setup only requesting AccessToken:

08-04 18:24:51.295: D/GamesUnitySDK(32436): Performing Android initialization of the GPG SDK
08-04 18:24:51.835: E/GamesNativeSDK(32436): Exception in dalvik/system/DexClassLoader.loadClass: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.NativeSdkEntryPoints" on path: /data/data/com.aarace.free/app_.gpg.classloader/de80b70ed0da0dfe988a41fa560612ee.jar.
08-04 18:24:51.920: I/GamesNativeSDK(32436): Auth operation started: SIGN IN
08-04 18:24:51.920: I/GamesNativeSDK(32436): Connecting to Google Play...
08-04 18:24:52.725: V/AuthAccountOperation(9516): offline access is not requested
08-04 18:24:52.730: V/BaseAuthAsyncOperation(9516): All scopes had been granted in the past, skip access token fetching
08-04 18:24:52.825: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 18:24:53.475: V/GamesNativeSDK(32436): Play Games callback indicates connection.
08-04 18:24:53.505: I/GamesNativeSDK(32436): Successfully connected to Google Play.
08-04 18:24:53.845: I/Unity(32436): Login was successful!
08-04 18:24:53.930: I/Unity(32436): jo_plusAccountApi: UnityEngine.AndroidJavaObject
08-04 18:24:53.945: I/Unity(32436): Calling GetApiClient....
08-04 18:24:54.170: V/AuthAccountOperation(9516): offline access is not requested
08-04 18:24:54.220: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 18:24:54.420: I/Unity(32436): Done GetApiClient is UnityEngine.AndroidJavaObject
08-04 18:24:54.420: I/Unity(32436): apiClient: UnityEngine.AndroidJavaObject
08-04 18:24:54.430: I/Unity(32436): GOOGLE EMAIL: [email protected]
08-04 18:24:54.435: I/Unity(32436): jo_plusAccountApi: UnityEngine.AndroidJavaObject
08-04 18:24:54.435: I/Unity(32436): Calling GetApiClient....
08-04 18:24:54.470: V/AuthAccountOperation(9516): offline access is not requested
08-04 18:24:54.470: V/BaseAuthAsyncOperation(9516): All scopes had been granted in the past, skip access token fetching
08-04 18:24:54.540: V/BaseAuthAsyncOperation(9516): access token request successful
08-04 18:24:54.545: I/Unity(32436): Done GetApiClient is UnityEngine.AndroidJavaObject
08-04 18:24:54.545: I/Unity(32436): apiClient: UnityEngine.AndroidJavaObject
08-04 18:24:54.675: I/Unity(32436): GOOGLE ACCESS TOKEN: ya29.xQE4kfk345lk23541kj5334l5j234l54kj23T3f8v7eTg_O4RV6-Ui235gfg4I-DFBtrNNY

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

With the update GameInfo files, you should not need to modify NativeClient. - This is the correct statement:
string scope = "audience:server:client_id:" + GameInfo.WebClientId;

I think what is happening is the references in NativeClient to the iOS client you added are not set (since you are running Android) and it is incorrectly trying to get the id token for null.

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

I reverted to the original NativeClient.cs and everything works!
Thanks a BUNCH for clarifying!

Keep up the excellent work and thanks for this token & webview feature which we were dearly missing :)
👍

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

iOS report:

BUILD ERROR:
Error occured during the iOS build, a missing reference.
FIX:
CustomWebViewApplication.mm:21
#import <GTMOAuth2Authentication.h>
changed to
#import <GoogleOpenSource/GTMOAuth2Authentication.h>

Login on iOS working!

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

I always convert the localUser, or in fact just reference the actual Google User for fear that Social.localUser may be referring in fact to the iOS GameCenter user.

While it doesn't look like your problem, it may be worth trying. Debugging those classes in iOS to see what's happening might be worth trying too. Just set a few breakpoints in CustomWebApplication.mm.

For the class that interacts with that side of things, I've this helper function,

private PlayGamesPlatform GooglePlayUser
{
    get { return PlayGamesPlatform.Instance; }
}

Which is then used like,

override protected void _Login()
{
    GooglePlayUser.Authenticate(Login);
}

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

EDIT: everything works, I messed up the client id in play console :\

That sadly didn't help either... Still getting FALSE.

So far tried the original from documentation:
PlayGamesPlatform.Activate();
Social.localUser.Authenticate(OnAuthenticate);
and the instance from documentation:
PlayGamesPlatform.Instance.localUser.Authenticate(OnAuthenticate);
and yours:
PlayGamesPlatform.instance.Authenticate(OnAuthenticate);

I don't know what I'm missing :\

from play-games-plugin-for-unity.

claywilkinson avatar claywilkinson commented on June 13, 2024

Can you post the log?

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

EDIT: everything works, I messed up the client id in play console :\

On first run:

2015-08-07 21:24:34.888 free[443:66986] INFO: Auth operation started: SIGN IN
2015-08-07 21:24:34.901 free[443:66986] INFO: Auth operation started: SIGN IN
GOOGLE AUTHENTICATE: False

on any other attempt:

2015-08-07 21:25:52.035 free[443:67136] INFO: Auth operation started: SIGN IN
GOOGLE AUTHENTICATE: False

I tried building both with cocoapods .xcworkspace and normal .xcodeproj with manual addition of gpg libraries with both success builds.

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

EDIT: everything works, I messed up the client id in play console :\

I also tried the combinations:

PlayGamesPlatform.Activate();
Social.localUser.Authenticate (OnAuthenticate);
2.
PlayGamesPlatform.Activate();
PlayGamesPlatform.Instance.localUser.Authenticate(OnAuthenticate);
3.
PlayGamesPlatform.Activate();
PlayGamesPlatform.Instance.Authenticate(OnAuthenticate);
Debug.Log for 1,2,3:

Social.Active: GooglePlayGames.PlayGamesPlatform
Social.localUser.authenticated: False
PlayGamesPlatform.Instance.IsAuthenticated(): False
PlayGamesPlatform.Instance.authenticated: False

Social.localUser.Authenticate (OnAuthenticate);
5.
PlayGamesPlatform.Instance.localUser.Authenticate(OnAuthenticate);
6.
PlayGamesPlatform.Instance.Authenticate(OnAuthenticate);
Debug.Log for 4,5,6:

Social.Active: UnityEngine.SocialPlatforms.GameCenter.GameCenterPlatform
Social.localUser.authenticated: False
PlayGamesPlatform.Instance.IsAuthenticated(): False
PlayGamesPlatform.Instance.authenticated: False

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

Just covering all the basic basics, you've obviously run, and have the correct values in for the iOS Setup stuff within Unity? And haven't changed some of those values since the last time you've done a build?

Also, if you're comfortable with it, I'd be happy to test for you, if you want to pass your details my way privately?

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

Email sent from my SixMinute company email.

from play-games-plugin-for-unity.

illa3d avatar illa3d commented on June 13, 2024

Oooo-kay. I'm a total tool. Although I have checked everything a bunch of times, one thing I completely missed is to check the Play console client id for the iOS application, which was wrong. Sorry for the time taken. /runs away

Thanks for this new feature set and solving the iOS rejection issue!
Much appreciated @seaders @claywilkinson

Shall we eliminate last redundant posts so we don't clutter space?

from play-games-plugin-for-unity.

seaders avatar seaders commented on June 13, 2024

Thing is, I find that's something that trips everyone (myself included) many times. I think it's the messaging that comes back is the worst part of it. On Android, if there's an incorrect key signing, it can give you no information at all, and just give you a continuous spinny wheel, and no information on screen, or in the logs. But then sometimes, it'll do like this, everything seems fine, but nothing actually works.

I know on Facebook, when you run that with debug mode, it spits loads of real information at you that really help get through issues like that, and it's one area where the main Google Play login stuffs would really help out with.

from play-games-plugin-for-unity.

Marurban avatar Marurban commented on June 13, 2024

Did anyone find a way to easily get authentication code?
Methods with invoking Android java methods doesn't work, getToken(...) is deprecated and I get an exception.

I found method:

public string GetAuthorizationCode(string serverClientID)

in source/PluginDev/Assets/GooglePlayGames/Platforms/Android/AndroidTokenClient.cs, when it will be implemented?

from play-games-plugin-for-unity.

W4der avatar W4der commented on June 13, 2024
using GooglePlayGames.BasicApi;
using GooglePlayGames;

string authCode; 
    void GetAuthCode()
    {
        Debug.Log("GetAuthCode");

        Social.localUser.Authenticate((bool success) =>
        {
            PlayGamesPlatform.Instance.GetServerAuthCode((CommonStatusCodes status, string code) =>
            {
                Debug.Log("Status: " + status.ToString());
                Debug.Log("Code: " + code);
                authCode = code;
            }
            );
        });
    }

from play-games-plugin-for-unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.