> ## 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.

# PFAuthenticationLoginWithGoogleAccountRequest

> 在 Android 上進行 Google 帳戶登入的要求資料。將 GoogleSignInAccount.getServerAuthCode() 傳回的驗證碼作為 ServerAuthCode 參數傳遞。

PFAuthenticationLoginWithGoogleAccountRequest 資料模型。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 存取權杖，並將其作為 AccessToken 參數傳遞給此 API。使用 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)).

## 語法

```cpp theme={null}
typedef struct PFAuthenticationLoginWithGoogleAccountRequest {  
    bool createAccount;  
    PFStringDictionaryEntry const* customTags;  
    uint32_t customTagsCount;  
    PFGetPlayerCombinedInfoRequestParams const* infoRequestParameters;  
    const char* playerSecret;  
    const char* serverAuthCode;  
    bool const* setEmail;  
} PFAuthenticationLoginWithGoogleAccountRequest;  
```

### 成員

**`createAccount`**   bool

如果目前沒有 PlayFab 帳戶連結至此識別碼，則自動建立一個。

**`customTags`**   PFStringDictionaryEntry const\*<br />*may be nullptr*

（選擇性）與要求相關聯的選擇性自訂標籤（例如組建編號、外部追蹤識別碼等）。

**`customTagsCount`**   uint32\_t

customTags 的計數

**`infoRequestParameters`**   PFGetPlayerCombinedInfoRequestParams const\*<br />*may be nullptr*

（選擇性）指定要為使用者傳回哪些資訊的旗標。

**`playerSecret`**   const char\*<br />*is null-terminated*

（選擇性）用來驗證 API 要求簽章的玩家密碼。

**`serverAuthCode`**   const char\*<br />*is null-terminated*

在用戶端上呼叫 getServerAuthCode() ([https://developers.google.com/identity/sign-in/android/offline-access](https://developers.google.com/identity/sign-in/android/offline-access)) Google 用戶端 API 所取得的 OAuth 2.0 伺服器驗證碼。

**`setEmail`**   bool const\*<br />*may be nullptr*

（選擇性）選擇性布林值，用來選擇在建立 Google 帳戶時不設定 MPA 電子郵件，預設為 true。

## 需求

**標頭：** PFAuthenticationTypes.h

## 另請參閱

[PFAuthenticationTypes 成員](/zh-TW/services/playfab/api-references/c/pfauthenticationtypes/pfauthenticationtypes_members)


## Related topics

- [PFAuthenticationLoginWithGoogleAccountAsync](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountasync.md)
- [PFAuthenticationReLoginWithGoogleAccountAsync](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationreloginwithgoogleaccountasync.md)
- [服務 C API 概觀 - PFAuthenticationTypes.h](/zh-TW/services/playfab/api-references/c/pfauthenticationtypes/pfauthenticationtypes_members.md)
- [PFAuthenticationLoginWithGoogleAccountGetResult](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountgetresult.md)
- [PFAuthenticationLoginWithGoogleAccountGetResultSize](/zh-TW/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithgoogleaccountgetresultsize.md)
