question

vokuchok@gmail.com avatar image
vokuchok@gmail.com asked

Question about Token for "login with google account"

Hi, I am interesting is possible to use PlayGamesPlatform.Instance.GetAccessToken method from https://github.com/playgameservices/play-games-plugin-for-unity ,  instead "Hamza extension" for login with Google Account ?

 

P.S. I tried that, but always I got a error code 400

 

 

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

If you haven't already, I would encourage having a look at our Login sample, here: https://github.com/PlayFab/Unity3d_Login_Example_Project/blob/8b59a9611f81b1c4c495caf703b22922bf27e0f4/README.md. We do reference using Hamza's plugin, which is what you're referring to, I believe.

A 400 error return is "Bad Request", and usually is caused by not passing the right parameters into a call, or passing in something invalid. The errorDetails on the return provides more complete info on the actual issue. Can you let us know what the errorDetails was in your testing?

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 ·
vokuchok@gmail.com avatar image
vokuchok@gmail.com answered

Hi,

I guess, what I found reason of 400 error code

03-04 12:09:27.440 12065-12114/? E/Unity: PlayFabLogin::OnGoogleLoginHasAccountError Error Code 400
03-04 12:09:27.513 12065-12114/? E/Unity: PlayFabLogin::OnGoogleLoginHasAccountError Error Message InvalidGoogleToken

But I don't know why token returned from GetAccessToken method, not correct.

Main reason of using GetAccessToken instead "Hamza extension": in "Hamza extension" always showing dialogue for select account (I mean select account window, where we selected google accout) its unlikely and weird behavior, because users already connected to google play services

 

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

Can you provide the specific code snippet from your project where you get the token and pass it into the Login call?

10 |1200

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

vokuchok@gmail.com avatar image
vokuchok@gmail.com answered

Hi,

This is my code, 

PlayGamesPlatform.Instance.Authenticate(delegate (bool state)
{
if (state)
{
Debug.Log("GooglePlayStrategy::AuthenticateLocalPlayer authenticate result: " + state);
PlayGamesPlatform.Instance.GetServerAuthCode(delegate (CommonStatusCodes statusCode, string token)
{
Debug.Log("GooglePlayStrategy::AuthenticateLocalPlayer statusCode " + statusCode + " token is " + token);
if (!string.IsNullOrEmpty(token))
{
LoginWithGoogleAccountRequest googlePlayeRequest = new LoginWithGoogleAccountRequest()
{
AccessToken = token,
CreateAccount = createAccount,
TitleId = PlayFabSettings.TitleId,
};

PlayFabClientAPI.LoginWithGoogleAccount(googlePlayeRequest, OnGoogleAccountLoginResult, OnGoogleLoginHasAccountError);
}
});
}
else
{
Debug.LogError("GooglePlayStrategy::AuthenticateLocalPlayer authenticate result: " + state);
}
10 |1200

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

vokuchok@gmail.com avatar image
vokuchok@gmail.com answered

Or you need code snippet, where I use Hamza extension?

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

We'd need both, to determine the issue - thanks.

10 |1200

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

vokuchok@gmail.com avatar image
vokuchok@gmail.com answered

With "Hamza Extension" I use method StartGooglePlusLogin from Playfab Login Example

I just copy/paste it to my project

that works fine, but ONE BIG PROBLEM when I call this method, I see this popup: http://take.ms/b0juw

This popup is a great barrier for users

P.S.: if you say me, how I can disable this dialogue in "Hamza Extension", it would be great. 

 

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 vokuchok,

Sorry for not being responsive about the Google Unity plugin...I'm now finishing testing new plugin that makes use of Google's refurbished sign in API.

What you described (in the screenshot) is not really an issue per say. The sign in is still handled by Google Play Services and I doubt it that it prompts a user who has already given consent to the app and signed in for account selection...However the new API looks much better and it explicitly handles "cached sessions" as shown in the docs. I'll keep you posted.

Since I don't think I'll have time to work on old plugin, it's available on github and you can try to modify its behaviour.

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

Vokuchok,

Multiple things here:

  1. The code you posted is not and will not work with Hamza's plugin. These are 2 separate plugins with different usages and capabilities.
  2. Copying and pasting only the google from the example will never work unless you have the corresponding plugins. Make sure that you also have the plugins from the example project.
  3. When you say that everything from StartGooglePlusLogin works fine, what do you mean? Were you able to authenticate with your Google ID?
  4. That pop-up you refer to is the normal and expected Google API behavior. If you do not like this, then you should consider a different login pathway. This is built into Android and each Android version looks slightly different.
  5. If you are looking for an easy and silent way to login users, check out this API.

 

Hope this helps clarify any remaining issues. Let us know if you have any further questions.

 

-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.

vokuchok@gmail.com avatar image
vokuchok@gmail.com answered

Hello Zac!

>1. The code you posted is not and will not work with Hamza's plugin. These are 2 separate plugins with different usages and capabilities.

Of course this code not work with Hamza's plugin because this code from Google Play Game Services (GPGS). I know what Hamza's plugin ang GPGS different plugins

2. Copying and pasting only the google from the example will never work unless you have the corresponding plugins. Make sure that you also have the plugins from the example project.

My main problem when I integraded Hamza's plugin is popup for accout selecting (so, I correct integrated Hamza's plugin, right?) 

3. When you say that everything from StartGooglePlusLogin works fine, what do you mean? Were you able to authenticate with your Google ID?

I mean, what your example works correct (get token method), when I integrated it to my project

4. That pop-up you refer to is the normal and expected Google API behavior. If you do not like this, then you should consider a different login pathway. This is built into Android and each Android version looks slightly different.

It's not normal. Because if I use GPGS I have already entered account name

 

 

 

 

10 |1200

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

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.