기술 자료

지원

Authentication

Open Unity Dashboard

Authentication

사용자 이름/비밀번호

Provide a username and password option to enable players to authenticate using custom credentials in your game.
읽는 시간 1분최근 업데이트: 한 달 전

최소 SDK 버전: 2.7.2
게임에서 사용자 이름/비밀번호를 사용해 플레이어의 인증을 설정하는 다음 시나리오를 참조하십시오.
  • 사용자 이름/비밀번호를 설정합니다.
  • 기존 사용자를 로그인시키거나 새 사용자를 생성합니다.
  • 익명 로그인에서 사용자 이름/비밀번호 계정을 통한 플랫폼 로그인으로 사용자를 업데이트합니다.
참고: 먼저 SDK를 초기화해야 합니다.

사용자 이름/비밀번호 설정

  1. Unity Authentication의 ID 제공업체를 사용자 이름/비밀번호로 설정합니다.
    1. Unity 에디터 메뉴에서 Edit > Project Settings... 로 이동한 후, Services > Authentication을 선택합니다.
    2. ID ProvidersUsername/Password로 설정한 후, Add를 선택합니다.
    3. Save를 선택합니다.

가입 또는 기존 플레이어 로그인

SignUpWithUsernamePasswordAsync
메서드를 통해 사용자 이름/비밀번호 자격 증명을 사용하여 새 플레이어를 생성합니다.
async Task SignUpWithUsernamePasswordAsync(string username, string password){ try { await AuthenticationService.Instance.SignUpWithUsernamePasswordAsync(username, password); Debug.Log("SignUp is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
SignInWithUsernamePasswordAsync
메서드를 통해 사용자 이름/비밀번호 자격 증명을 사용하여 기존 플레이어를 로그인시킵니다.
async Task SignInWithUsernamePasswordAsync(string username, string password){ try { await AuthenticationService.Instance.SignInWithUsernamePasswordAsync(username, password); Debug.Log("SignIn is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}

익명 로그인에서 사용자 이름/비밀번호 로그인으로 플레이어 업데이트

익명 인증을 설정한 후 익명 로그인에서 사용자 이름/비밀번호 계정을 생성하여 로그인하도록 플레이어를 업그레이드하려는 경우, 플레이어에게 자격 증명을 입력하는 창을 표시해야 합니다.
AddUsernamePasswordAsync
API를 호출하여 새 사용자 이름/비밀번호 계정을 생성한 다음 플레이어에게 추가합니다.
SDK에 캐시된 플레이어가 있는 경우, 새 사용자 이름/비밀번호를 생성하여 캐시된 플레이어에게 추가합니다.
  1. SignInAnonymouslyAsync
    를 사용해 캐시된 플레이어의 계정에 로그인합니다.
  2. 새 계정을 생성하고
    AddUsernamePasswordAsync
    를 사용해 생성된 계정을 캐시된 플레이어의 계정에 추가합니다.
async Task AddUsernamePasswordAsync(string username, string password){ try { await AuthenticationService.Instance.AddUsernamePasswordAsync(username, password); Debug.Log("Username and password added."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}

플레이어의 비밀번호 변경

플레이어에게 사용자 이름/비밀번호 계정의 비밀번호를 변경할 수 있는 옵션을 제공합니다. 사용자가 로그인되어 있어야 하며 현재 비밀번호새 비밀번호를 입력하도록 사용자에게 요청한 후,
UpdatePasswordAsync
를 호출해야 합니다.
UpdatePasswordAsync
는 사용자의 인증 상태를 유지하되 로그인된 다른 모든 기기에서는 사용자에게 다시 로그인하도록 요청합니다.
async Task UpdatePasswordAsync(string currentPassword, string newPassword){ try { await AuthenticationService.Instance.UpdatePasswordAsync(currentPassword, newPassword); Debug.Log("Password updated."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}