Skip to main content
PFAuthenticationLoginWithGoogleAccountRequest 数据模型。通过使用设备上的 Google Android 版登录 API 获取 Google OAuth 2.0 凭据并将其传递给此 API,可完成 Google 登录。如果这是用户首次使用 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)。

语法

成员

createAccount bool 如果当前没有 PlayFab 帐户链接到此 ID,则自动创建一个。 customTags PFStringDictionaryEntry const*
may be nullptr
(可选)与请求关联的可选自定义标记(例如生成号、外部跟踪标识符等)。 customTagsCount uint32_t customTags 的数量 infoRequestParameters PFGetPlayerCombinedInfoRequestParams const*
may be nullptr
(可选)标志,指示要为该用户返回哪些信息。 playerSecret const char*
is null-terminated
(可选)用于验证 API 请求签名的玩家密钥(仅限企业版)。 serverAuthCode const char*
is null-terminated
通过调用 getServerAuthCode() (https://developers.google.com/identity/sign-in/android/offline-access) Google 客户端 API 在客户端上获取的 OAuth 2.0 服务器身份验证代码。 setEmail bool const*
may be nullptr
(可选)可选的布尔值,用于选择在创建 Google 帐户时不设置 MPA 电子邮件,默认为 true。

要求

头文件: PFAuthenticationTypes.h

另请参阅

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