我有一个使用 Playfab 的 Unity 项目。 当我按下按钮时,我想使用 Google 帐户(点击一次)登录。我搜索了一些想法,但它总是使用谷歌玩游戏登录。
我试过:
void InitializePlayGamesLogin()
{
var config = new PlayGamesClientConfiguration.Builder()
// Requests an ID token be generated.
// This OAuth token can be used to
// identify the player to other services such as Firebase.
.RequestServerAuthCode(false)
.RequestEmail()
.AddOauthScope("profile")
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
public void LoginGoogle()
{
Social.localUser.Authenticate(OnGoogleLogin);
}
void OnGoogleLogin(bool success)
{
if (success)
{
string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
authCodeTxt.SetText(authCode);
PlayFabClientAPI.LoginWithGoogleAccount(new LoginWithGoogleAccountRequest()
{
TitleId = PlayFabSettings.TitleId,
ServerAuthCode = authCode,
CreateAccount = true
}, (result) =>
{
status.SetText("Signed in as " + result.PlayFabId);
}, OnPlayfabError
);
}
else
{
status.SetText("Unsuccessful login");
}
}
private void OnPlayfabError(PlayFab.PlayFabError playFabError)
{
status.SetText("Error "+ playFabError.GenerateErrorReport());
}
但它使用 Google Play Games 登录。