question

lkenn78 avatar image
lkenn78 asked

Unity - Playfab Login with Google Credentials - GetServerAuthCode returning null.,Unity : Logging into PlayFab using Google Credentials - GetServerAuthCode ?

Hi guys,

First attempt at playfab, so please be gentle.

I've been trying to log into playfab using google credentials. Logging in to GPGS is successful, but when I try to GetServerAuthCode() it fails, and returns a null.

Any help would be appreciated. Am ready to shoot myself.

Thanks.

Ps : ConsoleWrite is just a simple function that also writes to an on screen text so i an debug when running on device.

Pps : Also getting an error about delegates not matching the parameters.

public void GoogleLogin() {
  string serverAuthCode;

  ConsoleWrite("Attempting to Login to Google");

  Social.localUser.Authenticate((bool success) => {
    if (success) {
      ConsoleWrite("Authentication Success.");
      ConsoleWrite("Username : " + Social.localUser.userName + " | ID : " + Social.localUser.id);
    } else {
      ConsoleWrite("Authentication Failure.");
    }
  });

  ConsoleWrite("Attempting to Login to PlayFab using Google Credentials.");

  PlayGamesPlatform.Instance.GetServerAuthCode((CommonStatusCodes code, string tkn) => {
    ConsoleWrite("Code : " + code.ToString() + " | Token : " + tkn);serverAuthCode = tkn;
  });

  LoginWithGoogleAccountRequest request = new LoginWithGoogleAccountRequest {
    TitleId = titleId, ServerAuthCode = serverAuthCode, CreateAccount = true
  };

  PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginSuccess, OnLoginFailuer);
}

void OnLoginSuccess() {
  ConsoleWrite("PlayFab Login With Google - Success.");
}

void OnLoginFailuer() {
  ConsoleWrite("PlayFab Login With Google - Failure.");
}
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

·
brendan avatar image
brendan answered

Can you double-check that the configuration in Google is complete, per our guide (https://playfab.com/blog/setting-up-google-sign-in/)? Also, have a look at the way we're logging the error in the failure case - can you add that to your code, and let us know what the error details are?

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.

lkenn78 avatar image lkenn78 commented ·

OMG thanks so much @Brendan . Its already 5:30am here. Will look at it over the weekend and get back to you.

0 Likes 0 ·
lkenn78 avatar image lkenn78 commented ·

@brendan tested it out and it worked like a charm. Many thanks!

To add to that, if anyone wants to still use the GPGS functions, they can select "I'm already using Google APIs in my game".

After adding achievements/leaderboards, you can select "Get Resources" and copy/paste that piece of code into the GPGS>Android Setup in verbatim.

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.