I am using PlayFab for creating accounts in my Desktop Unity game. I want to allow users to login using google in my game. However, I do not know how to get the Server Auth code that LoginWithGoogleAccountRequest needs:
My code looks something like this:
using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;
public class LoginManager: MonoBehaviour
{
string GetServerAuthCode() {
}
void LoginUsingGoogle() {
var request = new LoginWithGoogleAccountRequest { CreateAccount = true, ServerAuthCode = GetServerAuthCode()};
PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginUsingThirdPartySuccess, OnLoginUsingThirdPartyFailure);
}
}
I want to write the appropriate code under GetServerAuthCode.
I know how to get the token, but I do not know how to get the server auth code:
public string GetToken() {
string[] scopes = {"https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"};
var credentials = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets {
ClientId = ClientId,
ClientSecret = SecretKey,
}, scopes, "user", CancellationToken.None);
return credentials.Result.Token.AccessToken;
}