PFAuthenticationLoginWithGoogleAccountAsync

让用户使用其 Google 帐户凭据登录

语法

HRESULT PFAuthenticationLoginWithGoogleAccountAsync(  
    PFServiceConfigHandle serviceConfigHandle,  
    const PFAuthenticationLoginWithGoogleAccountRequest* request,  
    XAsyncBlock* async  
)  

参数

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() 并将其作为 AccessToken 参数传递给此 API 来获取 OAuth 访问令牌。 使用 Google OAuth 2.0 访问令牌。 有关此更改的详细信息,请参阅 Google 开发人员文档 (https://android-developers.googleblog.com/2016/01/play-games-permissions-are-changing-in.html)。 异步任务完成后,调用 PFAuthenticationLoginWithGoogleAccountGetResult 获取结果。

要求

标头:PFAuthentication.h

另请参阅

PFAuthentication 成员