문서 메뉴
문서 홈
/ /
Atlas Device SDK
/ /

사용자 인증 - Java SDK

이 페이지의 내용

  • 로그인
  • 익명의 사용자
  • 이메일/비밀번호 사용자
  • API 키 사용자
  • 사용자 지정 JWT 사용자
  • 사용자 지정 기능 사용자
  • Facebook 사용자
  • Google 사용자
  • Apple 사용자
  • 오프라인 로그인
  • 사용자 액세스 토큰 받기
  • 사용자 로그아웃

Realm은 활성화된 인증 제공자를 사용하여 사용자를 인증하기 위한 API를 제공합니다. Credentials 객체를 인스턴스화하고 app.login() 또는 app.loginAsync() 메서드 중 하나에 전달하여 사용자 로그인을 인증하고 User 객체를 만듭니다. 각 인증 제공자는 해당 인증 제공자를 사용하여 Credentials 객체를 인스턴스화하는 데 사용되는 정적 도우미 메서드에 해당합니다.

애플리케이션 io.realm.mongodb.App 클래스 인스턴스의 app.login() 또는 app.loginAsync() 메서드를 사용하여 사용자를 인증할 수 있습니다. app.login() 메서드는 제공된 자격 증명이 사용자 인증에 성공하거나 실패할 때까지 호출 스레드에서 코드 실행을 차단하는 반면, app.loginAsync() 메서드는 실행을 계속 허용하여 실행이 보장된 콜백 함수를 사용하여 성공 또는 실패를 처리합니다. app.loginAsync() 를 호출한 동일한 스레드에서

성공하면 app.login() 메서드는 User 객체를 반환합니다. 이벤트의 경우, app.login() 메서드에서 ObjectServerError 유형의 예외가 발생합니다.

app.loginAsync() 메서드에 콜백을 전달하여 성공 또는 실패를 처리합니다. 이 콜백은 App.Result 유형의 단일 매개 변수를 허용합니다. 콜백에 전달된 App.Result 객체의 isSuccess() 메서드는 작업의 성공 여부를 나타내는 부울을 반환합니다. 이벤트가 발생하면 getError() 메서드를 사용하여 오류를 일으킨 오류를 볼 수 있습니다.

익명 인증 제공자 를 사용하면 사용자가 영구적인 개인 정보를 저장하지 않는 단기 계정으로 애플리케이션에 로그인할 수 있습니다. 익명 인증으로 로그인하려면 Credentials.anonymous() 를 호출하여 익명 자격 증명을 생성한 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
Credentials anonymousCredentials = Credentials.anonymous();
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(anonymousCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated anonymously.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
val anonymousCredentials: Credentials = Credentials.anonymous()
var user: User?
app.loginAsync(anonymousCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated anonymously.")
user = app.currentUser()
} else {
Log.e("AUTH", it.error.toString())
}
}

이메일/비밀번호 인증 제공자 를 통해 사용자는 이메일 사용자 이름과 비밀번호로 애플리케이션에 로그인할 수 있습니다. 이메일/비밀번호 인증으로 로그인하려면 사용자의 이메일과 비밀번호로 Credentials.emailPassword() 에 전화를 걸어 이메일/비밀번호 자격 증명을 생성합니다. 그런 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
Credentials emailPasswordCredentials = Credentials.emailPassword("<email>", "<password>");
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(emailPasswordCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using an email and password.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
val emailPasswordCredentials: Credentials = Credentials.emailPassword(
"<email>",
"<password>"
)
var user: User? = null
app.loginAsync(emailPasswordCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated using an email and password.")
user = app.currentUser()
} else {
Log.e("AUTH", it.error.toString())
}
}

API 키 인증 제공자 를 사용하면 사용자가 클라이언트 SDK에서 자동으로 생성된 API 키를 사용하여 애플리케이션에 로그인할 수 있습니다. API 키 인증으로 로그인하려면 API 키로 Credentials.apiKey() 를 호출하여 API 키 자격 증명을 생성합니다. 그런 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
Credentials apiKeyCredentials = Credentials.apiKey("<key>");
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(apiKeyCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using an API Key.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
val apiKeyCredentials: Credentials = Credentials.apiKey("<key>")
var user: User? = null
app.loginAsync(apiKeyCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated using an API Key.")
user = app.currentUser()
} else {
Log.e("AUTH", "Error logging in: ${it.error.toString()}")
}
}

사용자 지정 JSON web token 인증 제공자 를 사용하면 사용자가 사용자 지정 JSON web token 으로 애플리케이션에 로그인할 수 있습니다. 사용자 지정 JSON web token 인증으로 로그인하려면 사용자 지정 JSON web token으로 Credentials.jwt() 을(를) 호출하여 사용자 지정 JSON web token 자격 증명을 생성합니다. 그런 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
// fetch JWT from custom provider
Credentials customJWTCredentials = Credentials.jwt("<token>");
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(customJWTCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using a custom JWT.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
// fetch JWT from custom provider
val customJWTCredentials: Credentials = Credentials.jwt("<token>")
var user: User? = null
app.loginAsync(customJWTCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated using a custom JWT.")
user = app.currentUser()
} else {
Log.e("AUTH", "Error logging in: ${it.error.toString()}")
}
}

사용자 지정 함수 인증 제공자 를 사용하면 사용자가 앱에 정의된 Realm 함수 를 사용하여 애플리케이션에 로그인할 수 있습니다. 사용자 지정 함수 인증으로 로그인하려면 Credentials.customFunction() 을(를) 호출하여 자격 증명을 생성합니다. customFunction() 메서드에는 Realm 인증 함수에서 사용하는 속성과 값이 포함된 문서가 필요합니다. 예를 들어 백엔드 함수가 다음과 같이 입력 매개변수에 username 이라는 필드가 포함될 것으로 예상한다고 가정해 보겠습니다.

exports = async function(loginPayload) {
const { username } = loginPayload;
...
}

Credentials.customFunction() 에 전달하는 문서는 다음과 같습니다.

Document("username", "bob")

그런 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID).build());
Credentials customFunctionCredentials =
Credentials.customFunction(new org.bson.Document("username", "bob"));
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(customFunctionCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using a custom function.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
val customFunctionCredentials:
Credentials = Credentials.customFunction(org.bson.Document("username", "bob"))
var user: User? = null
app.loginAsync(customFunctionCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated using a custom function.")
user = app.currentUser()
} else {
Log.e("AUTH", "Error logging in: ${it.error.toString()}")
}
}

Facebook 인증 제공자를 사용하면 기존 Facebook 계정을 사용하여 Facebook 앱을 통해 사용자를 인증할 수 있습니다.

중요

Facebook 인증 공급자 활성화

기존 Facebook 계정으로 사용자를 로그인하려면 애플리케이션에 대한 인증 공급자를 구성하고 활성화해야 합니다.

중요

Facebook 프로필 사진 URL 저장 안 함

Facebook 프로필 사진 URL에는 이미지 권한을 부여하는 사용자의 액세스 토큰이 포함되어 있습니다. 보안을 위해 사용자의 액세스 토큰이 포함된 URL을 저장하지 마세요. 대신 이미지를 가져와야 할 때 사용자의 메타데이터 필드에서 직접 URL에 액세스합니다.

Android용 공식 Facebook 로그인 팔로우하기 빠른 시작 애플리케이션에 대한 인증 흐름을 설정합니다. 로그인 완료 핸들러에서 Facebook LoginResult 에서 로그인한 사용자의 액세스 토큰을 가져옵니다. . 액세스 토큰을 사용하여 Realm Facebook 자격 증명을 만든 다음 사용자를 Realm 앱에 로그인합니다.

FacebookSdk.setApplicationId(YOUR_FACEBOOK_SDK_APP_ID);
FacebookSdk.sdkInitialize(activity);
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// Signed in successfully, forward credentials to MongoDB Realm.
AccessToken accessToken = loginResult.getAccessToken();
Credentials facebookCredentials = Credentials.facebook(accessToken.getToken());
app.loginAsync(facebookCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully logged in to MongoDB Realm using Facebook OAuth.");
} else {
Log.e("AUTH", "Failed to log in to MongoDB Realm", it.getError());
}
});
}
@Override
public void onCancel() {
Log.v("AUTH", "Facebook authentication cancelled.");
}
@Override
public void onError(FacebookException exception) {
Log.e("AUTH", "Failed to authenticate using Facebook: " + exception.getMessage());
}
}
);
LoginManager.getInstance().logIn(activity, null);
FacebookSdk.setApplicationId(YOUR_FACEBOOK_SDK_APP_ID)
FacebookSdk.sdkInitialize(activity)
val callbackManager = CallbackManager.Factory.create()
LoginManager.getInstance().registerCallback(
callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
// Signed in successfully, forward credentials to MongoDB Realm.
val accessToken = loginResult.accessToken
val facebookCredentials: Credentials =
Credentials.facebook(accessToken.token)
app.loginAsync(facebookCredentials) {
if (it.isSuccess) {
Log.v(
"AUTH",
"Successfully logged in to MongoDB Realm using Facebook OAuth."
)
} else {
Log.e("AUTH", "Failed to log in to MongoDB Realm", it.error)
}
}
}
override fun onCancel() {
Log.v("AUTH", "Cancelled Facebook login")
}
override fun onError(exception: FacebookException) {
Log.e("AUTH", "Failed to authenticate with Facebook: ${exception.message}")
}
})

중요

기존 Google 계정으로 사용자를 로그인하려면 애플리케이션에 대해 Google 인증 제공자를 구성하고 활성화해야 합니다.

Google 사용자 인증을 위해 애플리케이션을 설정하려면 다음을 수행합니다.

  1. Google Cloud Platform 콘솔 에서, OAuth 2 를 만듭니다.0 '웹 애플리케이션' 유형의 클라이언트 ID입니다.

  2. 해당 클라이언트 ID와 연결된 클라이언트 시크릿을 사용하도록 백엔드 앱을 구성합니다.

  3. 백엔드에서 OpenID Connect 활성화

Android용 Google의 공식 로그인 사용 Android 애플리케이션에서 Google 사용자를 인증합니다:

참고

아래 코드 예시

이러한 지침의 구현은 아래 코드 블록을 확인하세요.

  1. 애플리케이션 수준 build.gradledependencies 블록에 Android용 Google 로그인 종속성을 추가합니다.

    com.google.android.gms:play-services-auth:19.2.0
  2. GoogleSignInOptions 만들기 다음 빌더 옵션을 사용합니다.

  3. 를 사용하여 GoogleSignInOptions GoogleSignInClient GoogleSignIn.getClient()로 를 만듭니다.

  4. GoogleSignInClient 를 사용하여 Google 로그인을 트리거할 수 있는 Intent 을 만듭니다.

  5. RegisterForActivityResult() 사용 콜백을 구성합니다. 콜백은 GoogleSignIn.getSignedInAccountFromIntent() 를 사용해야 합니다. Google 로그인 결과에 액세스합니다: Task<GoogleSignInAccount>.

  6. 시작() ActivityResultLauncher 의 메서드 이전 단계에서 반환되어 Google 로그인을 시작합니다. launch() 메서드를 Google 로그인 Intent 에 전달합니다.

  7. isSuccessful() 을(를) 사용하여 Google 로그인 오류를 처리합니다.

  8. 작업 결과(GoogleSignInAccount)을 getResult() 와 함께 사용합니다.

  9. getIdToken() 을(를) 사용하여 GoogleSignInAccount 의 ID 토큰에 액세스합니다.

  10. Credentials.google() 을 사용하여 Realm Credentials 객체를 만듭니다. 첫 번째 매개변수로 ID 토큰을 전달하고 두 번째 매개변수로 GoogleAuthType.ID_TOKEN 을 전달합니다.

  11. app.loginAsync() 또는 app.login() 메서드를 사용하여 토큰을 사용하여 Atlas App Services 백엔드로 인증합니다.

다음 코드는 loginWithGoogle() 에 대한 메서드 호출로 시작하여 이 흐름을 구현합니다.

private void signInWithGoogle() {
GoogleSignInOptions gso = new GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("YOUR WEB APPLICATION CLIENT ID FOR GOOGLE AUTH")
.build();
GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(this, gso);
Intent signInIntent = googleSignInClient.getSignInIntent();
ActivityResultLauncher<Intent> resultLauncher =
registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
Task<GoogleSignInAccount> task =
GoogleSignIn.getSignedInAccountFromIntent(result.getData());
handleSignInResult(task);
}
});
resultLauncher.launch(signInIntent);
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
if (completedTask.isSuccessful()) {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
String token = account.getIdToken();
Credentials googleCredentials =
Credentials.google(token, GoogleAuthType.ID_TOKEN);
app.loginAsync(googleCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH",
"Successfully logged in to MongoDB Realm using Google OAuth.");
} else {
Log.e("AUTH",
"Failed to log in to MongoDB Realm: ", it.getError());
}
});
} else {
Log.e("AUTH", "Google Auth failed: "
+ completedTask.getException().toString());
}
} catch (ApiException e) {
Log.w("AUTH", "Failed to log in with Google OAuth: " + e.getMessage());
}
}
fun loginWithGoogle() {
val gso = GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("YOUR WEB APPLICATION CLIENT ID FOR GOOGLE AUTH")
.build()
val googleSignInClient = GoogleSignIn.getClient(this, gso)
val signInIntent: Intent = googleSignInClient.signInIntent
val resultLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult())
{ result ->
val task: Task<GoogleSignInAccount> =
GoogleSignIn.getSignedInAccountFromIntent(result.data)
handleSignInResult(task)
}
resultLauncher.launch(signInIntent)
}
fun handleSignInResult(completedTask: Task<GoogleSignInAccount>) {
try {
if (completedTask.isSuccessful) {
val account: GoogleSignInAccount? = completedTask.getResult(ApiException::class.java)
val token: String = account?.idToken!!
val googleCredentials: Credentials =
Credentials.google(token, GoogleAuthType.ID_TOKEN)
app.loginAsync(googleCredentials) {
if (it.isSuccess) {
Log.v(
"AUTH",
"Successfully logged in to MongoDB Realm using Google OAuth."
)
} else {
Log.e("AUTH",
"Failed to log in to MongoDB Realm", it.error)
}
}
} else {
Log.e("AUTH", "Google Auth failed: ${completedTask.exception}")
}
} catch (e: ApiException) {
Log.e("AUTH", "Failed to authenticate using Google OAuth: " + e.message);
}
}

다음도 참조하세요.

Android용 Google 로그인에 대해 자세히 알아보려면 공식 Android용 Google 로그인 통합 가이드를 확인하세요.

Apple 인증 제공자 로 로그인을 사용하면 사용자가 Apple에서 제공하는 사용자 지정 토큰을 사용하여 애플리케이션에 로그인할 수 있습니다. Apple로 로그인 인증으로 로그인하려면 Apple에서 제공한 토큰으로 Credentials.apple() 를 호출하여 Apple로 로그인 자격 증명을 생성합니다. 그런 다음 생성된 자격 증명을 app.login() 또는 app.loginAsync() 에 전달합니다.

String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
// fetch apple token using Apple SDK
Credentials appleCredentials = Credentials.apple("<token>");
AtomicReference<User> user = new AtomicReference<User>();
app.loginAsync(appleCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using Sign-in with Apple.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
val appID = YOUR_APP_ID // replace this with your App ID
val app: App = App(
AppConfiguration.Builder(appID)
.build()
)
// fetch IDToken using Apple SDK
val appleCredentials: Credentials = Credentials.apple("<token>")
var user: User? = null
app.loginAsync(appleCredentials) {
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated using Sign-in with Apple.")
user = app.currentUser()
} else {
Log.e("AUTH", "Error logging in: ${it.error.toString()}")
}
}

token contains an invalid number of segments(이)라는 Login failed 오류가 발생하면 JWT의 UTF-8 인코딩 문자열 버전을 전달하고 있는지 확인하세요.

Atlas App Services는 액세스 토큰 및 새로 고침 토큰으로 세션을 managed합니다. 클라이언트 SDK는 토큰 managed 로직을 제공하며 요청 시 토큰을 제공합니다.

SDK는 이러한 토큰을 공유 기본 설정 에 저장합니다. .

다음도 참조하세요.

Realm 애플리케이션이 사용자를 인증하면 사용자의 자격 증명을 캐시합니다. 기존 사용자 자격 증명을 확인하여 로그인 흐름을 우회하고 캐시된 사용자에 액세스할 수 있습니다. 이 기능을 사용하여 오프라인에서 Realm을 열 수 있습니다.

참고

최초 로그인 시에는 네트워크 연결이 필요합니다.

사용자가 앱에 가입하거나 클라이언트의 기존 계정으로 처음으로 로그인하는 경우 클라이언트가 네트워크에 연결되어 있어야 합니다. 캐시된 사용자 자격 증명을 확인하면 오프라인에서 Realm을 열 수 있지만 이는 사용자가 이전에 온라인 상태에서 로그인한 적이 있는 경우에만 가능합니다.

// Log the user into the backend app.
// The first time you login, the user must have a network connection.
String appID = YOUR_APP_ID; // replace this with your App ID
App app = new App(new AppConfiguration.Builder(appID)
.build());
// Check for an existing user.
// If the user is offline but credentials are
// cached, this returns the existing user.
AtomicReference<User> user = new AtomicReference<User>();
user.set(app.currentUser());
if (user.get() == null) {
// If the device has no cached user
// credentials, log them in.
Credentials anonymousCredentials = Credentials.anonymous();
app.loginAsync(anonymousCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated anonymously.");
user.set(app.currentUser());
} else {
Log.e("AUTH", it.getError().toString());
}
});
}
// Log the user into the backend app.
// The first time you login, the user must have a network connection.
val appID = YOUR_APP_ID // replace this with your App ID
val app = App(
AppConfiguration.Builder(appID)
.build()
)
// Check for an existing user.
// If the user is offline but credentials are
// cached, this returns the existing user.
val user =
AtomicReference<User?>()
user.set(app.currentUser())
if (user.get() == null) {
// If the device has no cached user
// credentials, log them in.
val anonymousCredentials =
Credentials.anonymous()
app.loginAsync(
anonymousCredentials
) { it: App.Result<User?> ->
if (it.isSuccess) {
Log.v("AUTH", "Successfully authenticated anonymously.")
user.set(app.currentUser())
} else {
Log.e("AUTH", it.error.toString())
}
}
}

사용자가 로그인하면 Atlas App Services는 사용자에게 앱에 대한 액세스 권한을 부여하는 액세스 토큰을 생성합니다. Realm SDK는 액세스 토큰을 자동으로 관리하고 만료되면 갱신하며 각 요청마다 현재 사용자에 대한 유효한 액세스 토큰을 포함합니다. Realm은 새로 고침 토큰을 자동으로 갱신 하지 않습니다. 새로 고침 토큰이 만료되면 사용자는 다시 로그인해야 합니다.

SDK 외부로 요청을 보내는 경우 각 요청에 사용자의 액세스 토큰을 포함하고 토큰이 만료되면 수동으로 새로 고쳐야 합니다.

다음 예와 같이 SDK의 Realm.User 객체에서 로그인한 사용자의 액세스 토큰에 액세스하고 새로 고칠 수 있습니다.

// Gets a valid user access token to authenticate requests
public String getValidAccessToken(User user) {
// An already logged in user's access token might be stale. To
// guarantee that the token is valid, refresh it if necessary.
user.refreshCustomData();
return user.getAccessToken();
}
// Gets a valid user access token to authenticate requests
fun getValidAccessToken(user: User?): String {
// An already logged in user's access token might be stale. To
// guarantee that the token is valid, refresh it if necessary.
user!!.refreshCustomData()
return user.accessToken
}

user.logOut() 또는 user.logOutAsync() 메서드를 사용하면 로그인에 사용한 인증 제공자와 관계없이 모든 사용자를 로그아웃할 수 있습니다. 두 방법 모두:

  • 장치에서 로컬로 저장된 사용자 자격 증명 삭제

  • 사용자 Realm과의 모든 동기화 즉시 중지

로그아웃하면 동기화가 중단되므로 모든 로컬 Realm 업데이트가 서버에 업로드된 후에만 로그아웃해야 합니다.

user.get().logOutAsync( result -> {
if (result.isSuccess()) {
Log.v("AUTH", "Successfully logged out.");
} else {
Log.e("AUTH", result.getError().toString());
}
});
user?.logOutAsync {
if (it.isSuccess) {
Log.v("AUTH", "Successfully logged out.")
} else {
Log.e("AUTH", it.error.toString())
}
}

돌아가기

사용자 생성 및 삭제

다음

사용자 지정 사용자 데이터