I am using playfab sdk in unity to login with play games. But when I call LoginWithGoogle request of playfab, I get this error:
Error logging in player with custom ID: Google API error code: invalid_request details: Invalid Credentials
<>c:<LoginWithGoogle>b__68_1(PlayFabError)
System.Delegate:DynamicInvokeImpl(Object[])
PlayFab.Internal.ResultContainer`1:WrapCallback(Delegate, Object)
PlayFab.Internal.ResultContainer`1:HandleResults(CallRequestContainer, Delegate, ErrorCallback, Action`2)
PlayFab.Internal.<MakeRequestViaUnity>d__14:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Here's my code to login:
public void LoginGooglePlayGames()
{
PlayGamesPlatform.Instance.Authenticate((success) =>
{
if (success == SignInStatus.Success)
{
Debug.Log("Login with Google Play games successful.");
PlayGamesPlatform.Instance.RequestServerSideAccess(false, code =>
{
Debug.Log("Authorization code: " + code);
Debug.Log("name " + PlayGamesPlatform.Instance.GetUserDisplayName());
playFabManager.LoginWithGoogle(code);
});
}
else
{
Debug.Log("Login Unsuccessful");
}
});
}
public void LoginWithGoogle(int token)
{
LoginWithGoogleAccountRequest request = new LoginWithGoogleAccountRequest()
{
TitleId = PlayFabSettings.TitleId,
CreateAccount = true,
AccessToken = token
};
PlayFabClientAPI.LoginWithGoogleAccount(request, (result) =>
{
PlayFabId = result.PlayFabId;
Debug.Log("Got PlayFabID: " + PlayFabId);
if (result.NewlyCreated)
{
Debug.Log("(new account)");
UserInfo info = new UserInfo();
info.PlayerName = GameManager.Instance.nameMy;
info.LoggedType = LoginType.Google.ToString();
info.Coins.Gold = StaticStrings.initCoinsCountFacebook;
info.Coins.Gems = StaticStrings.initGemsCountFacebook;
info.Meta.Avatar = -1;
info.Meta.AvatarURL = GameManager.Instance.AvatarURL;
info.Meta.UserID = GameManager.Instance.UserID;
Database.Instance.UpdateAllData(info);
}
else
{
CheckIfFirstTitleLogin(PlayFabId, true);
Debug.Log("(existing account)");
}
GetPhotonToken();
},
(error) =>
{
Debug.Log("Error logging in player with custom ID: " + error.ErrorMessage + "\n" + error.ErrorDetails);
GameManager.Instance.connectionLost.showDialog();
});
}
I have google addon installed on playfab.
And web client id created in google cloud platform