Skip to main content
使用用户的 Google 帐户凭据为用户登录

语法

参数

serviceConfigHandle PFServiceConfigHandle 从 PFServiceConfigCreateHandle 调用返回的 PFServiceConfigHandle。 request PFAuthenticationLoginWithGoogleAccountRequest* 已填充的请求对象。 async XAsyncBlock*
Inout
用于异步操作的 XAsyncBlock。

返回值

类型:HRESULT 此 API 操作的结果代码。

备注

此 API 可在 Android 上使用。Google 登录通过在设备上使用适用于 Android API 的 Google 登录获取 Google OAuth 2.0 凭据,然后将其传递给此 API 来完成。如果这是用户首次使用 Google 帐户登录且 CreateAccount 设为 true,将创建一个新的 PlayFab 帐户并链接到该 Google 帐户。否则,如果没有 PlayFab 帐户链接到该 Google 帐户,将返回相应的错误,以便游戏引导用户创建 PlayFab 帐户。目前(推荐)在 Android 应用程序中获取 Google 帐户凭据的方法是调用 GoogleSignInAccount.getServerAuthCode() 并将授权代码作为此 API 的 ServerAuthCode 参数发送。在执行此操作之前,必须在 Google API 控制台中创建 OAuth 2.0 Web 应用程序客户端 ID,并在 PlayFab Game Manager Google 加载项中为你的游戏配置其客户端 ID 和密钥。此方法无需向用户提示其他 Google 帐户权限,因此可获得摩擦最少的用户体验。有关获取服务器授权代码的详细信息,请参阅 https://developers.google.com/identity/sign-in/android/offline-access。以前(已弃用)的方法是通过在客户端上调用 GetAccessToken() 获取 OAuth 访问令牌,并将其作为 AccessToken 参数传递给此 API,用于 Google OAuth 2.0 访问令牌。有关此更改的详细信息,请参阅 Google 开发人员文档 (https://android-developers.googleblog.com/2016/01/play-games-permissions-are-changing-in.html)。异步任务完成后,调用 PFAuthenticationLoginWithGoogleAccountGetResult 获取结果。

要求

头文件: PFAuthentication.h

另请参阅

PFAuthentication 成员
最后修改于 2026年8月13日