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

# Migrer de Google Sign-in vers Google Play Games dans Unity

> Étapes de migration détaillées pour faire passer les joueurs Unity de la connexion avec un compte Google à LoginWithGooglePlayGamesServices, y compris la liaison et la vérification.

# Procédure de migration vers l'API LoginWithGooglePlayGamesServices

La migration consiste à passer à LoginWithGooglePlayGamesServices, puisque Google encourage les développeurs à migrer vers ce mode d'authentification. Après la migration des joueurs, il n'y aura plus de dépendance envers l'API LoginWithGoogleAccount et les développeurs devraient pouvoir passer à la dernière version du plugiciel.

Pour plus d'information, consultez la [documentation officielle de Google](https://developers.google.com/games/services/android/signin#migrate_to_play_games_services_sign_in_v2).

## Étapes générales

1. Choisir la bonne version de « Play Games Plugin for Unity ».
2. Initialiser Play Games Platform et authentifier l'utilisateur.
3. Se connecter à PlayFab à l'aide de LoginWithGoogleAccount.
4. Lier votre profil Google Play Games au compte de joueur PlayFab.
5. Vérifier que l'utilisateur peut se connecter à l'aide de l'API LoginWithGooglePlayGamesServices.
6. (Facultatif) Dissocier votre profil de compte Google du compte de joueur PlayFab.

## Étapes de migration

### Choisir la bonne version de « Play Games Plugin for Unity »

Les versions les plus récentes du plugiciel ne fonctionnent pas pour la migration, car Google ne permet plus de demander des étendues supplémentaires; l'API LoginWithGoogleAccount de PlayFab ne fonctionne donc plus.

Ces étapes de migration ont été testées et documentées à l'aide de la version 0.10.14 de « Play Games Plugin for Unity », que vous trouverez ici : [playgameservices/play-games-plugin-for-unity at v10.14 (github.com)](https://github.com/playgameservices/play-games-plugin-for-unity/tree/v10.14)

Pour les étapes d'installation et de configuration du plugiciel, consultez le [README](https://github.com/playgameservices/play-games-plugin-for-unity/blob/v10.14/README.md) du plugiciel

### Initialiser Play Games Platform et authentifier le joueur

Consultez la [section Configuration & Initialization Play Games Services du README](https://github.com/playgameservices/play-games-plugin-for-unity/blob/v10.14/README.md#configuration--initialization-play-game-services) et demandez l'étendue « profile » dans le cadre de PlayGamesClientConfiguration.

```csharp theme={null}
 PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
     .AddOauthScope("profile")
     .RequestServerAuthCode(false)
     .Build();
 
 PlayGamesPlatform.InitializeInstance(config);
 // recommended for debugging:
 PlayGamesPlatform.DebugLogEnabled = true;
 // Activate the Google Play Games platform
 PlayGamesPlatform.Activate();
 
 // authenticate user:
 PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, (SignInStatus result) => {
     if (result == SignInStatus.Success)
     {
         Debug.Log("Authentication Succeeded.");
     }
     else
     {
         Debug.Log("Authentication Failed. SignInStatus: " + result);
     }
 });
```

### Se connecter à PlayFab à l'aide de LoginWithGoogleAccount

Connectez-vous au compte existant du joueur à l'aide de l'API d'authentification [LoginWithGoogleAccount](https://learn.microsoft.com/en-us/rest/api/playfab/client/authentication/login-with-google-account?view=playfab-rest). Pour réussir la connexion, vous devez fournir un Server Auth Token, qui peut être demandé au moyen de la méthode GetServerAuthCode.

```csharp theme={null}
 public void PlayFabLoginWithGoogleAccount()
 {
     var serverAuthCode = PlayGamesPlatform.Instance.GetServerAuthCode();

     var request = new LoginWithGoogleAccountRequest
     {
         ServerAuthCode = serverAuthCode,
         TitleId = PlayFabSettings.TitleId
     };
 
     PlayFabClientAPI.LoginWithGoogleAccount(request, OnLoginWithGoogleAccountSuccess, OnLoginWithGoogleAccountFailure);
 }

 private void OnLoginWithGoogleAccountSuccess(LoginResult result)
 {
     Debug.Log("PlayFab LoginWithGoogleAccount Success.");
 }

 private void OnLoginWithGoogleAccountFailure(PlayFabError error)
 {
     Debug.Log("PlayFab LoginWithGoogleAccount Failure: " + error.GenerateErrorReport());
 }
```

Avant toute migration, un utilisateur lié au compte Google s'affiche comme suit dans [Game Manager](https://developer.playfab.com) :

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-1.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=6831f4c076155602f1661a9e7822656a" alt="Migration vers LoginWithGooglePlayGamesServices - étape 1" width="921" height="304" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-1.png" />

### Lier le profil Google Play Games du joueur au compte de joueur PlayFab

Dans cette étape, vous liez le compte Google Play Games du joueur au compte PlayFab existant du joueur, qui était auparavant lié uniquement au compte Google.

```csharp theme={null}
public void LinkGooglePlayGamesAccount()
{
    PlayGamesPlatform.Instance.GetAnotherServerAuthCode(true, (serverAuthCode) => {

        var linkRequest = new LinkGooglePlayGamesServicesAccountRequest
        {
            ServerAuthCode = serverAuthCode
        };

        PlayFabClientAPI.LinkGooglePlayGamesServicesAccount(linkRequest, OnLinkGooglePlayGamesServicesAccountSuccess, OnLinkGooglePlayGamesServicesAccountFailure);
    });
}

private void OnLinkGooglePlayGamesServicesAccountSuccess(LinkGooglePlayGamesServicesAccountResult result)
{
    Debug.Log("PlayFab LinkGooglePlayGamesServicesAccount Success");
}

private void OnLinkGooglePlayGamesServicesAccountFailure(PlayFabError error)
{
    Debug.Log("PlayFab LinkGooglePlayGamesServicesAccount Failure: " + error.GenerateErrorReport());
}
```

Après cette étape, le joueur devrait avoir les deux profils de compte associés du côté de PlayFab et devrait pouvoir commencer à utiliser l'API d'authentification [LoginWithGooglePlayGamesServices](https://learn.microsoft.com/en-us/rest/api/playfab/client/authentication/login-with-google-play-games-services?view=playfab-rest) dès maintenant.

Si vous accédez à [Game Manager](https://developer.playfab.com), vous voyez les deux comptes associés au joueur, comme illustré :

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-2.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=c0a4ea9b73a4d5a2dcdaa326dfce3e63" alt="Migration vers LoginWithGooglePlayGamesServices - étape 2" width="774" height="294" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-2.png" />

### Vérifier que le joueur peut se connecter à l'aide de l'API LoginWithGooglePlayGamesServices

```csharp theme={null}

 public void PFLoginWithGooglePlayGames()
 {
     PlayGamesPlatform.Instance.GetAnotherServerAuthCode(true, (serverAuthCode) => {

         var request = new LoginWithGooglePlayGamesServicesRequest
         {
             ServerAuthCode = serverAuthCode,
             CreateAccount = false,
             TitleId = PlayFabSettings.TitleId
         };
 
         PlayFabClientAPI.LoginWithGooglePlayGamesServices(request, OnLoginWithGooglePlayGamesServicesSuccess, OnLoginWithGooglePlayGamesServicesFailure);
     });
 }

 private void OnLoginWithGooglePlayGamesServicesSuccess(LoginResult result)
 {
     Debug.Log("PlayFab LoginWithGooglePlayGamesServices Success.");
 }

 private void OnLoginWithGooglePlayGamesServicesFailure(PlayFabError error)
 {
     Debug.Log("PlayFab LoginWithGooglePlayGamesServices Failure: " + error.GenerateErrorReport());
 }

```

### (Facultatif) Dissocier votre profil de compte Google du compte de joueur PlayFab

Cette étape est facultative. Cependant, si vous avez déjà confirmé que le profil Google Play Games Services est lié au compte du joueur et qu'il peut se connecter à PlayFab avec succès, vous voudrez probablement dissocier tous les profils de compte Google précédemment liés au profil du joueur à l'aide de l'API [UnlinkGoogleAccount](https://learn.microsoft.com/en-us/rest/api/playfab/client/account-management/unlink-google-account?view=playfab-rest), et passer à l'utilisation exclusive de l'API [LoginWithGooglePlayGamesServices](https://learn.microsoft.com/en-us/rest/api/playfab/client/authentication/login-with-google-play-games-services?view=playfab-rest).

```csharp theme={null}
 public void UnlinkGoogleAccountFromPlayer()
 {
     PlayFabClientAPI.UnlinkGoogleAccount(new UnlinkGoogleAccountRequest(), OnUnlinkGoogleAccountSuccess, OnUnlinkGoogleAccountFailure);
 }
 
 private void OnUnlinkGoogleAccountSuccess(UnlinkGoogleAccountResult result)
 {
     Debug.Log("PlayFab UnlinkGoogleAccount Success.");
 }
 
 private void OnUnlinkGoogleAccountFailure(PlayFabError error)
 {
     Debug.Log("PlayFab UnlinkGoogleAccount Failure: " + error.GenerateErrorReport());
 }
```

Après la dissociation, vous ne devriez voir que l'identité Google Play Games dans [Game Manager](https://developer.playfab.com) pour le joueur :

<img src="https://mintcdn.com/microsoft-4404708b/mLCHf0iQv3VidfBe/images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-3.png?fit=max&auto=format&n=mLCHf0iQv3VidfBe&q=85&s=1e0da657f9f650df7ec1009d4bfdf2dd" alt="Migration vers LoginWithGooglePlayGamesServices - étape 3" width="800" height="289" data-path="images/playfab/identity/player-identity/platform-specific-authentication/tutorials/google-unity/LWGPGS-migration-procedure-3.png" />


## Related topics

- [Migrer les jeux Unity vers la connexion Google Play Games](/fr-CA/services/playfab/identity/player-identity/platform-specific-authentication/google-play-games-sign-in-migration.md)
- [Solution de repli pour la migration de Google Sign-in vers la connexion Play Games](/fr-CA/services/playfab/identity/player-identity/platform-specific-authentication/google-play-games-sign-in-migration-fallback.md)
- [Authentification PlayFab avec Google Play Games Sign-In dans Unity](/fr-CA/services/playfab/identity/player-identity/platform-specific-authentication/google-sign-in-unity.md)
- [Authentification propre à la plateforme](/fr-CA/services/playfab/identity/player-identity/platform-specific-authentication/index.md)
- [Configuration de l'authentification PlayFab avec Google et HTML5](/fr-CA/services/playfab/identity/player-identity/platform-specific-authentication/google-html5.md)
