question

Jedrzej Jonasz avatar image
Jedrzej Jonasz asked

Login with Google token issue

Hi, I'm having some trouble with the google access token for loginWithGoogle request. I am getting the message "Invalid input parameters" when I try to use the token I get from the Google Play Game Services Unity plugin with the call: 

((PlayGamesLocalUser)Social.localUser).idToken

I get can login to google using the plugin just fine, and it looks like I'm getting a token back from google in ADB. 

Getting ID token.  Scope = audience:server:client_id: ....

I'm not sure if I setup my client id stuff on google's game services dashboard. I originally created an android client but then got a message that I need to create a "web" linked client. I created one and it asked me for a url where my app was located, so I put in my website but maybe I was supposed to use the playfabapi.com url?

-JJ

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

I would recommend having a look at our Login sample, as it shows a complete end-to-end for this. In particular, have a look at the sample code provided by Hamza Lazaar, which is referenced in the readme: https://github.com/PlayFab/Unity3d_Login_Example_Project

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Just making sure all the other threads on this topic have the updated info: We do now support the newer Google authentication (ServerAuthCode) process. Please see this post for more information: https://playfab.com/blog/setting-up-google-sign-in/.

0 Likes 0 ·
Jedrzej Jonasz avatar image
Jedrzej Jonasz answered

Hi,

Thank you for pointing out that link. I couldn't find any information though about how to setup the linked app in google play services to work with playfab. Do you if I should create a linked web app and if so what the URL should be so that it works with playfab?

-JJ

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey JJ,

You do not need any special linkage to PlayFab to use LoginWithGoogle. That being said, you will need to have your GooglePlay and Google Developer consoles linked and the proper APIs enabled.

Steps:

1) Link your GooglePlay Project to your Google Developer Console

2) Enable Google+ API in your linked console project

3) Build your client embedded with the required android libraries. For Unity, this requires a third-party plugin. We have a sample Android project you can use for getting started here. Our example only provides coverage over the most basic scenarios. For more in-depth Google+ features you will want to extend the code provided or look into a retail plugin. 

4) Call GoogleAuthUtil to obtain your token 

5) Pass your token to PlayFab via LoginWithGoogle.

6) You should get a success callback with a valid session ticket. 

 

Let us know if you have any further issues and we will be happy to assist. 

Thanks,

Zac

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jedrzej Jonasz avatar image
Jedrzej Jonasz answered

@Zac, thanks. I have the API linked, but when you set it up it asks you what kind of app

http://cl.ly/3R0L3V2K1A1S

So, first I selected Android, and in the ADB log I got a message that I needed to setup a web app to get the token. So I setup a web app and used my website as the URL. Now I get a token that shows up in the log.

So is the token that the play games sdk (https://github.com/playgameservices/play-games-plugin-for-unity) give you via ((PlayGamesLocalUser)Social.localUser).idToken  different than the one that is retrieved with those plugin scripts from Hamza? because I am getting a token, it's just not accepted by playfab, so maybe they are different?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

JJ,

First off I will say that I am not that familiar with the google play games plugin, as it did not perform the proper getToken functionality. Perhaps they have added it recently. From what I can tell, by looking at the API docs, it seems like this would get you the proper token; however, there are additional setup instructions for the unity plugin, ensure that those are completed.

Next, there are other settings that you must check to ensure they are linked correctly: 

  • Your console developer project needs to have the Google+ API enabled. 
  • Your GoogleDeveloper console is linked to your API console in two places: linked via the GooglePlay > Settigns > Services & APIs. I believe you need to do this at both the application level and the overall level.

Hamza's plugin was a work-arond to using the gpg unity plugin.

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Also, I would like to point out a point out that I noticed a difference in the GooglePlay setup instructions. They are configuring a web app, where as for PlayFab's titles we created an Android app link using the details from the corresponding Google Console. I believe this should work in both cases; as what is truly required is the Oauth2 client ID which is provided on the Linked Apps screen:

GooglePlay Console > Game Services > <Your Title> > Linked Apps 

 

 

If you haven't already also may need (depending on the plug-in) to enable GooglePlayGames services in your API console:

 

If you continue to have issues then the the gpg plugin may still not be in sync with what this Google Auth API provides.

 

-Zac

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jason Irvan avatar image
Jason Irvan answered

Is that the correct token Jedrzej? The PlayFab API says it's looking for the accessToken, not the idToken. That would be:

 

(((PlayGamesLocalUser) Social.localUser).accessToken

 

I'm about to test this same setup myself in the next day or so. I'll post back my findings later if I learn anything new.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @"Jedrzej Jonasz", @"Jason Irvan", do you have updates regarding Google tokens?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Adam Brzozowski avatar image
Adam Brzozowski answered

I have worked with a co-worker to figure out the problem with the GooglePlayGames plugin for unity. The problem is that the plugin starts an async process when you request the accessToken for the first time.

What we had to do to work around the problem was if we were authenticated, request the access token until it wasn't null. We had this in a coroutine that would have .25f sec ways between each attempt. Usually by the 3rd attempt we would have a valid accessToken and could move forward. Not elegant by any means but do with it what you will.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Adam,

Thanks for the insight on the GPG Plugin. We worked with Hamza to create our plugin to work around the limitations of the GPG plugin. That being said, our plugin only provides minimum functionality for obtaining the Google+ ID for testing our API and to provide an example for our developers. 

 

Happy Developing,

Zac

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

psanchez avatar image psanchez commented ·

Hello Zac and Hamza.

I've been looking for the Login example proyect but I can't find it in your GitHub (the link goes to a 404). With the GPG plugin for unity, I can get the AuthToken (with GetServerAuthCode) but PlayFab needs the Access Token. Do you know a way to get that token from the Auth Token? Or have you move your plugin to some other place, so I can take a look at it?

Thank you for your help

0 Likes 0 ·
brendan avatar image brendan psanchez commented ·

That link takes me to the correct GitHub project, so it's not clear why it wouldn't be working for you. Can you get a screenshot showing this error (including the URL being hit)?

0 Likes 0 ·
psanchez avatar image psanchez brendan commented ·

This is the 404 error when I try to access de Login Example Project. And inside the PlayFab github I can't find it, either

0 Likes 0 ·
github.png (263.9 KiB)
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.