사용자 이름/비밀번호
Provide a username and password option to enable players to authenticate using custom credentials in your game.
읽는 시간 1분최근 업데이트: 한 달 전
최소 SDK 버전: 2.7.2
게임에서 사용자 이름/비밀번호를 사용해 플레이어의 인증을 설정하는 다음 시나리오를 참조하십시오.- 사용자 이름/비밀번호를 설정합니다.
- 기존 사용자를 로그인시키거나 새 사용자를 생성합니다.
- 익명 로그인에서 사용자 이름/비밀번호 계정을 통한 플랫폼 로그인으로 사용자를 업데이트합니다.
사용자 이름/비밀번호 설정
- Unity Authentication의 ID 제공업체를 사용자 이름/비밀번호로 설정합니다.
- Unity 에디터 메뉴에서 Edit > Project Settings... 로 이동한 후, Services > Authentication을 선택합니다.
- ID Providers를 Username/Password로 설정한 후, Add를 선택합니다.
- Save를 선택합니다.
가입 또는 기존 플레이어 로그인
SignUpWithUsernamePasswordAsyncasync 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); }}
SignInWithUsernamePasswordAsyncasync 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- 를 사용해 캐시된 플레이어의 계정에 로그인합니다.
SignInAnonymouslyAsync - 새 계정을 생성하고 를 사용해 생성된 계정을 캐시된 플레이어의 계정에 추가합니다.
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); }}
플레이어의 비밀번호 변경
플레이어에게 사용자 이름/비밀번호 계정의 비밀번호를 변경할 수 있는 옵션을 제공합니다. 사용자가 로그인되어 있어야 하며 현재 비밀번호와 새 비밀번호를 입력하도록 사용자에게 요청한 후,UpdatePasswordAsyncUpdatePasswordAsyncasync 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); }}