> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFAuthenticationLoginWithGoogleAccountAsync

> 使用使用者的 Google 帳戶認證將使用者登入

使用使用者的 Google 帳戶認證將使用者登入

## 語法

```cpp theme={null}
HRESULT PFAuthenticationLoginWithGoogleAccountAsync(  
    PFServiceConfigHandle serviceConfigHandle,  
    const PFAuthenticationLoginWithGoogleAccountRequest* request,  
    XAsyncBlock* async  
)  
```

### 參數

**`serviceConfigHandle`**   PFServiceConfigHandle

從 PFServiceConfigCreateHandle 呼叫傳回的 PFServiceConfigHandle。

**`request`**   [PFAuthenticationLoginWithGoogleAccountRequest\*](/zh-TW/services/playfab/api-references/c/pfauthenticationtypes/structs/pfauthenticationloginwithgoogleaccountrequest)

已填入資料的要求物件。

**`async`**   XAsyncBlock\*<br />*Inout*

用於非同步作業的 XAsyncBlock。

### 傳回值

類型：HRESULT

此 API 作業的結果代碼。

## 備註

此 API 可在 Android 上使用。Google 登入的完成方式為：在裝置上使用 Google sign-in for Android API 取得 Google OAuth 2.0 認證，並將其傳遞給此 API。如果這是使用者第一次以 Google 帳戶登入，且 CreateAccount 設為 true，系統將建立新的 PlayFab 帳戶，並將其連結至該 Google 帳戶。否則，如果沒有任何 PlayFab 帳戶連結至該 Google 帳戶，將會傳回表示此情況的錯誤，讓遊戲可以引導使用者建立 PlayFab 帳戶。目前 (建議) 在 Android 應用程式中取得 Google 帳戶認證的方法，是呼叫 GoogleSignInAccount.getServerAuthCode()，並將驗證碼作為此 API 的 ServerAuthCode 參數傳送。在執行此動作之前，您必須在 Google API Console 中建立 OAuth 2.0 Web 應用程式用戶端識別碼，並在遊戲的 PlayFab Game Manager Google 附加元件中設定其用戶端識別碼和密碼。此方法不需要提示使用者授予額外的 Google 帳戶權限，因此能提供最流暢的使用者體驗。如需取得伺服器驗證碼的詳細資訊，請參閱 [https://developers.google.com/identity/sign-in/android/offline-access](https://developers.google.com/identity/sign-in/android/offline-access)。先前 (已淘汰) 的方法是在用戶端上呼叫 GetAccessToken() 取得 OAuth 存取權杖，並將其作為此 API 的 AccessToken 參數傳遞。搭配 Google OAuth 2.0 存取權杖使用。如需此變更的詳細資訊，請參閱 Google 開發人員文件 ([https://android-developers.googleblog.com/2016/01/play-games-permissions-are-changing-in.html](https://android-developers.googleblog.com/2016/01/play-games-permissions-are-changing-in.html))。非同步工作完成時，請呼叫 [PFAuthenticationLoginWithGoogleAccountGetResult](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountgetresult) 以取得結果。

## 需求

**標頭：** PFAuthentication.h

## 另請參閱

[PFAuthentication 成員](/zh-TW/services/playfab/api-references/c/pfauthentication/pfauthentication_members)


## Related topics

- [PFAuthenticationLoginWithGoogleAccountGetResultSize](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountgetresultsize.md)
- [PFAuthenticationLoginWithGoogleAccountGetResult](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountgetresult.md)
- [服務 C API 概觀 - PFAuthentication.h](/zh-TW/services/playfab/api-references/c/pfauthentication/pfauthentication_members.md)
- [PFAuthenticationReLoginWithGoogleAccountAsync](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationreloginwithgoogleaccountasync.md)
- [PFAuthenticationLoginWithGoogleAccountRequest](/zh-TW/services/playfab/api-references/c/pfauthenticationtypes/structs/pfauthenticationloginwithgoogleaccountrequest.md)
