question

Nicolas De Zubiria Cano avatar image
Nicolas De Zubiria Cano asked

Is there a way to check if the Google play account already exists?

Hello, I'm wondering if there is a way to detect if a Google account already exists in the database. This is because I need to allow the user to also set the Username he wants before login with Google because as soon as the user logs with Google the username can't be changed, or at least i haven't found a way to set the username after the Google login.

10 |1200

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

1 Answer

·
Seth Du avatar image
Seth Du answered

Here is one quick solution:

  1. The player clicks Login with Google button
  2. Client calls LoginWithGoogleAccount API with "CreateAccount" as false in the request
  1. If it succeeded, it means account already exists and the player logs in
  2. If it failed, the Google account doesn’t exist in the system. You will first, keep the ServerAuthCode you used, then ask the player to input username/email as long as passwordfor registration (RegisterPlayFabUser API). After the success callback, call LinkGoogleAccount using the ServerAuthCode you kept previously.

Besides, you may also use 3-rd party tools like SnowFlake to run advanced query for this Linking Google Account events.

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

Nicolas De Zubiria Cano avatar image Nicolas De Zubiria Cano commented ·

Hi! Thanks for the replay. I will try what you're suggesting. Now I have a question, if I first register the player with the RegisterPlayFabUser and then i link the Google account, the email and password is not going to be the one from Google Play right? It will be the one that the player input in the registration. How can I male use of the Google Play email and password and save then with the user info in playfab. Thanks in advance.

0 Likes 0 ·
Nicolas De Zubiria Cano avatar image Nicolas De Zubiria Cano commented ·

Hi SethDu, after the first attempt with the GoogleAuthenticate that fails because no Google account was found, I'm performing a SilenthAuth, then I'm adding the Username, Email and Password that the player typed, then linking that SilentAuth account with the Google account. The thing is that when i try to link to the Google account it says InvalidGoogleToken, and if I'm not doing things wrong I'm using the same ServerAuthCode from the first attempt to login with Google.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Nicolas De Zubiria Cano commented ·

Have you tried to generate a new auth code in case it is only for single use.

0 Likes 0 ·
Nicolas De Zubiria Cano avatar image Nicolas De Zubiria Cano Seth Du ♦ commented ·

Hi man, yes I did generate a new auth code and I got it working. Thanks!

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.