Share via


LoginWithGooglePlayGamesServices API 마이그레이션 절차

마이그레이션은 Google이 개발자에게 이 인증 방식으로 마이그레이션하도록 권장하기 때문에 LoginWithGooglePlayGamesServices로 전환하는 것으로 구성됩니다. 플레이어를 마이그레이션한 후에는 LoginWithGoogleAccount API에 대한 종속성이 없으며 개발자는 최신 플러그인 버전으로 업그레이드할 수 있어야 합니다.

자세한 내용은 Google 공식 설명서를 참조하세요.

높은 수준의 단계

  1. 올바른 버전의 "Play Games Plugin for Unity"를 선택하십시오.
  2. Play 게임 플랫폼을 초기화하고 사용자를 인증합니다.
  3. LoginWithGoogleAccount를 사용하여 PlayFab에 로그인합니다.
  4. Google Play 게임 프로필을 PlayFab 플레이어 계정과 연결합니다.
  5. 사용자가 LoginWithGooglePlayGamesServices API를 사용하여 로그인할 수 있는지 확인합니다.
  6. (선택 사항) PlayFab 플레이어 계정에서 Google 계정 프로필을 연결 해제합니다.

마이그레이션 단계

"Unity용 Play 게임 플러그인"의 올바른 버전을 선택하세요.

Google에서 더 이상 추가 범위 요청을 허용하지 않으므로 최신 버전의 플러그인이 마이그레이션에 작동하지 않으므로 PlayFab의 LoginWithGoogleAccount API가 더 이상 작동하지 않습니다.

이러한 마이그레이션 단계는 "Unity용 Play Games 플러그 인" 버전 0.10.14를 사용하여 테스트 및 문서화되었으며 playgameservices/play-games-plugin-for-unity v10.14(github.com)에서 확인할 수 있습니다.

플러그인 설치 및 구성 단계는 플러그인의 README를 참조하세요.

Play 게임 플랫폼 초기화 및 플레이어 인증

README 구성 및 Play Games 서비스 초기화 섹션을 참조하고 PlayGamesClientConfiguration의 일부로 "프로필" 범위를 요청합니다.

 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);
     }
 });

LoginWithGoogleAccount를 사용하여 PlayFab에 로그인합니다.

LoginWithGoogleAccount 인증 API를 사용하여 기존 플레이어의 계정에 로그인합니다. 성공적으로 로그인하려면 GetServerAuthCode 메서드를 통해 요청할 수 있는 서버 인증 토큰을 제공해야 합니다.

 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());
 }

이전을 수행하기 전에 Google 계정에 연결된 사용자는 게임 관리자에 다음과 같이 표시됩니다.

LoginWithGooglePlayGamesServices 1단계로 마이그레이션

이 단계에서는 플레이어의 Google Play 게임 계정을 이전에 Google 계정에만 연결된 기존 플레이어의 PlayFab 계정과 연결합니다.

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());
}

이 단계 후에 플레이어는 PlayFab의 끝에 연결된 두 계정 프로필을 가지고 있어야 하며 지금부터 LoginWithGooglePlayGamesServices 인증 API를 사용할 수 있어야 합니다.

게임 관리자로 이동하면 다음과 같이 플레이어와 연결된 두 계정이 모두 표시됩니다.

LoginWithGooglePlayGamesServices로 마이그레이션 2단계

LoginWithGooglePlayGamesServices API를 사용하여 플레이어가 로그인할 수 있는지 확인합니다.


 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());
 }

이 단계는 옵션입니다. 그러나 Google Play 게임 서비스 프로필이 플레이어 계정에 연결되어 있고 PlayFab에 성공적으로 로그인할 수 있음을 이미 확인한 경우 UnlinkGoogleAccount를 사용하여 플레이어의 프로필에 연결된 이전 Google 계정 프로필의 연결을 해제하고 LoginWithGooglePlayGamesServices API만 사용하도록 이동합니다.

 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());
 }

연결을 해제하면 플레이어의 게임 관리자에 Google Play 게임 ID만 표시됩니다.

LoginWithGooglePlayGamesServices로 마이그레이션 3단계