question

pnbmlgame avatar image
pnbmlgame asked

Google Login for Android and iOS

Hey, I cannot get the Google Login and PlayFab LoginWithGoogleAccount to work. Can anyone help me to get the OAuth2.0 Token for Android and iOS? Apparently the Tokens I get from Google Play Games SDK are being rejected by PlayFab. @Brendan @Hamza Lazaar Any help with proper steps will be highly appreciated.

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

pnbmlgame avatar image pnbmlgame commented ·
void Start () {
	PlayGamesPlatform.Activate ();
}


public void RequestLoginToGoogle (LoginSource a_loginSource) {
	_localUser = new LocalUser ();
	Social.localUser.Authenticate (cbOnLoginComplete);
}

void cbOnLoginComplete (bool a_bSuccess) {
	if (a_bSuccess) {
		PlayGamesPlatform.Instance.GetServerAuthCode (cbOnServerAuthReceived);
	}
}

private void cbOnServerAuthReceived (CommonStatusCodes a_statusCodes, string a_strAccessToken) {
	m_strGoogleAccessToken = a_strAccessToken;
}

PS: This is the code that I have written for Logging in with Google Play Games

0 Likes 0 ·
Hamza Lazaar avatar image
Hamza Lazaar answered
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 ·
pnbmlgame avatar image
pnbmlgame answered

Hey Hamza, did not work.

Heres the code to get the IdToken()

void cbOnLoginComplete (bool a_bSuccess) {
	if (a_bSuccess) {
		PlayGamesPlatform.Instance.GetIdToken (cbOnIDTokenRecieved);
		//PlayGamesPlatform.Instance.GetServerAuthCode (cbOnServerAuthReceived);
	}
}


void cbOnIDTokenRecieved (string a_strIDToken) {
	if (m_strGoogleAccessToken == "") {
		AppendText ("GoogleHandler :: cbOnIDTokenRecieved :: a_strIDToken : " + a_strIDToken);
		m_strGoogleAccessToken = a_strIDToken;
		if (m_loginSource == LoginSource.LoginHandler) {
			LoginHandler.Instance.OnGoogleLoginComplete ();
		}
	}
}

This is the log

GoogleHandler :: cbOnIDTokenRecieved :: a_strIDToken : eyJhbGciOiJSUzI1NiIsImtpZCI6ImI5N2FmM2E4OTk4MzJmNTU1ODAzOWQ1NDg4MzY0ZDEyOWViNmE3YjcifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWF0IjoxNDgyODI2MzgwLCJleHAiOjE0ODI4Mjk5ODAsImF1ZCI6IjE4Njg0Mzg5OTIyLXFwZHRlaXJmbmEwNnBzZWJjbXM5NWQ2MnZnZGI5amcwLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTA0OTAwOTUxNTI0MzE3NzkyNTMzIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF6cCI6IjE4Njg0Mzg5OTIyLXZmdmhwOWhoM2FoYTU0MGZubWw0dm5xaTgycjk1b2NvLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJtYXJpb29qb2pvQGdtYWlsLmNvbSIsIm5hbWUiOiJKYXkgVm9yYSIsImdpdmVuX25hbWUiOiJKYXkiLCJmYW1pbHlfbmFtZSI6IlZvcmEifQ.PFBQ1t25ZVMmx7A8JNKA95tsIi_ynJUEMYfR0IyyzaHRjf495BC8RtDDvnTJNBm3txXDM3D_LnJZd8JZIkaxPgJtDcr9OVJ4dCNYT_tRnMevsMQPpTa7Ku3je63og9-IY5jG73XLUohM-zOxJ0Doxp32UrVBe5RJaBhhXgyKeUJeiFgbvhGtEBqnc_GepCe5JK1YDcIcoJ2lfNreE_ET4US9bxFGStJ7wg0R5y_FctLoYNAq5OS6ui1iiPandnTt5PTA7GN2jblhRnx19t4Re3cWA8k7uVtpmy1EQwubQWOCTv35PEg25Rrg8yedNzfof8DlKDqQlD1B4pdb-O_RTQ
12-27 13:50:10.460  9738  9763 I Unity   :
12-27 13:50:10.460  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/D
12-27 13:50:10.462  9738  9763 I Unity   : *eyJhbGciOiJSUzI1NiIsImtpZCI6ImI5N2FmM2E4OTk4MzJmNTU1ODAzOWQ1NDg4MzY0ZDEyOWViNmE3YjcifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWF0IjoxNDgyODI2MzgwLCJleHAiOjE0ODI4Mjk5ODAsImF1ZCI6IjE4Njg0Mzg5OTIyLXFwZHRlaXJmbmEwNnBzZWJjbXM5NWQ2MnZnZGI5amcwLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTA0OTAwOTUxNTI0MzE3NzkyNTMzIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF6cCI6IjE4Njg0Mzg5OTIyLXZmdmhwOWhoM2FoYTU0MGZubWw0dm5xaTgycjk1b2NvLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJtYXJpb29qb2pvQGdtYWlsLmNvbSIsIm5hbWUiOiJKYXkgVm9yYSIsImdpdmVuX25hbWUiOiJKYXkiLCJmYW1pbHlfbmFtZSI6IlZvcmEifQ.PFBQ1t25ZVMmx7A8JNKA95tsIi_ynJUEMYfR0IyyzaHRjf495BC8RtDDvnTJNBm3txXDM3D_LnJZd8JZIkaxPgJtDcr9OVJ4dCNYT_tRnMevsMQPpTa7Ku3je63og9-IY5jG73XLUohM-zOxJ0Doxp32UrVBe5RJaBhhXgyKeUJeiFgbvhGtEBqnc_GepCe5JK1YDcIcoJ2lfNreE_ET4US9bxFGStJ7wg0R5y_FctLoYNAq5OS6ui1iiPandnTt5PTA7GN2jblhRnx19t4Re3cWA8k7uVtpmy1EQwubQWOCTv35PEg25Rrg8yedNzfof8DlKDqQlD1B4pdb-O_RTQ*
12-27 13:50:10.462  9738  9763 I Unity   :
12-27 13:50:10.462  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:10.462  9738  9763 I Unity   :
12-27 13:50:10.588  9738  9763 I Unity   : GoogleHandler :: cbOnIDTokenRecieved
12-27 13:50:10.588  9738  9763 I Unity   :
12-27 13:50:10.588  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:10.588  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : PlayFabManager :: RequestLoginWithGoogle :: Error :: HTTP: 400
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : PlayFabManager :: RequestLoginWithGoogle :: Error :: HTTP Status: BadRequest
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : PlayFabManager :: RequestLoginWithGoogle :: Error :: Error Detail:
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : PlayFabManager :: RequestLoginWithGoogle :: Error :: Error MessageInvalid Google token
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.509  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
12-27 13:50:12.509  9738  9763 I Unity   :
12-27 13:50:12.522  9738  9763 I Unity   : PlayFabManager :: OnApiCallError :: ERROR :: HTTP:400
12-27 13:50:12.522  9738  9763 I Unity   :  ERROR:InvalidGoogleToken -- Invalid Google token
12-27 13:50:12.522  9738  9763 I Unity   :
12-27 13:50:12.522  9738  9763 I Unity   :
12-27 13:50:12.522  9738  9763 I Unity   :
12-27 13:50:12.522  9738  9763 I Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
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.

pnbmlgame avatar image pnbmlgame commented ·
0 Likes 0 ·
Hamza Lazaar avatar image
Hamza Lazaar answered

I assume the PlayFab error you are getting when calling LoginWithGoogleAccount is InvalidGoogleToken. It looks like the token given by GetIdToken is the from the new "v3" sign in API. Which should be supported by PlayFab as @Brendan mentioned once but I wasn't able to login using it.

I'm not sure about GetServerAuthCode().

Can you post the results of that call? The v2 token should be shorter.

I'm not really familiar with Google Play Games Unity integration.

I suggest you try the Unity Android plugin I made and I'm using (I guess other PlayFab customers do as well). For iOS I can't really help you.

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

Hamza Lazaar avatar image Hamza Lazaar commented ·

There is a new Firebase Unity SDK that offers tons of free stuff! Authentication is included. I'm trying it out now.

0 Likes 0 ·
pnbmlgame avatar image pnbmlgame Hamza Lazaar commented ·

Thanks for this update! We are also going to try it out now. We tried using your plugin earlier, but then we needed iOS too. So went to GooglePlayGames SDK because it said it could give us both. But apparently it does not.

Will post the result of the call for GetServerAuthCode() shortly.

0 Likes 0 ·
pnbmlgame avatar image
pnbmlgame answered
@Hamza Lazaar @Brendan

Any update on the Google+ Login? Out game has been stalled before release since 1 month because of this.

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 ·

We're currently working on an update to our Google authentication model, to support the updated GPG server tokens. But that said, it's currently possible to use the previous token model with our service, as well as any of our other authentication systems, including the Custom ID login, which would let you define your own identification scheme.

0 Likes 0 ·

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.