비밀번호 대용 Smart Lock을 Android 앱에 통합하려면 Credentials API 호출을 앱의 시작 및 로그인 흐름에 추가해야 합니다. 다음 다이어그램은 비밀번호 대용 Smart Lock을 사용하는 일반적인 Android 앱의 흐름을 보여줍니다.
비밀번호 대용 Smart Lock을 성공적으로 통합하는 방법에는 여러 가지가 있으며 통합의 세부 사항은 앱의 구조와 사용자 환경에 따라 다르지만 대부분의 앱에서 다음 흐름이 권장됩니다. 이 흐름을 사용하는 앱은 다음과 같은 사용자 환경 이점을 제공합니다.
하나의 사용자 인증 정보가 저장된 서비스 기존 사용자는 즉시 로그인되며, 사용자가 앱을 열면 로그인된 뷰로 바로 이동합니다.
여러 사용자 인증 정보를 저장했거나 자동 로그인을 사용 중지한 사용자는 하나의 대화상자에만 응답해야 앱의 로그인된 뷰로 이동할 수 있습니다.
사용자 인증 정보를 저장하지 않았거나 아직 가입하지 않은 사용자는 탭 한 번으로 이름과 이메일을 선택하여 이 정보가 미리 채워진 지능적으로 로그인 또는 가입 보기로 이동할 수 있습니다.
사용자가 로그아웃하면 앱에서 사용자가 자동으로 다시 로그인되지 않도록 합니다.
사용자 인증 정보 검색
앱이 시작될 때 이미 로그인한 사용자가 없으면 CredentialsClient.request()를 호출합니다.
Task에 성공하면 getResult().getCredential()로 사용자의 사용자 인증 정보를 가져와서 로그인합니다.
Task가 실패하고 ResolvableApiException 인스턴스가 예외이고 getStatusCode()가 RESOLUTION_REQUIRED을 반환하는 경우 사용자 인증 정보를 선택하려면 사용자 입력이 필요합니다. startResolutionForResult()를 호출하여 사용자에게 저장된 계정을 선택하라는 메시지를 표시하고 getParcelableExtra(Credential.EXTRA_KEY)를 호출하여 사용자의 사용자 인증 정보를 가져오고 이를 사용하여 로그인합니다.
사용자 인증 정보 저장
Task가 실패하고 ApiException이 반환되고 getStatusCode()가 SIGN_IN_REQUIRED를 반환하면 사용자에게 저장된 사용자 인증 정보가 없으므로 현재 로그인 또는 가입 과정을 통해 수동으로 로그인하거나 가입해야 합니다. 사용자가 로그인을 정상적으로 완료하면 사용자가 나중에 검색할 수 있도록 사용자 인증 정보를 저장할 수 있는 기회를 제공할 수 있습니다 (5단계).
사용자의 이메일 주소와 같은 로그인 힌트를 검색하여 사용자가 더 빠르고 쉽게 로그인하거나 가입하도록 지원할 수 있습니다. 사용자는 힌트를 선택하여 사용자 인증 정보 입력을 건너뛸 수 있습니다. 앱에서 사용자에게 로그인이 필요한 경우 초기 사용자 인증 정보 요청이 실패한 직후 힌트를 가져오도록 선택할 수 있습니다. 그러지 않으면 사용자가 로그인 또는 가입 흐름을 시작할 때까지 기다릴 수 있습니다.
CredentialsClient.getHintPickerIntent()를 호출하고 사용자에게 계정을 선택하라는 메시지를 표시하는 인텐트를 시작한 다음 getParcelableExtra(Credential.EXTRA_KEY)를 호출하여 로그인 힌트를 가져옵니다.
힌트의 사용자 ID가 기존 사용자와 일치하면 이 ID로 로그인 양식을 미리 작성하고 사용자가 비밀번호를 입력하여 로그인하도록 합니다.
힌트의 사용자 ID가 기존 사용자와 일치하지 않으면 사용자의 ID와 이름으로 가입 양식을 미리 채우고 사용자가 새 계정을 만들도록 합니다.
사용자가 로그인하거나 계정을 만든 후 CredentialsClient.save()로 사용자 ID와 비밀번호를 저장합니다.
사용자가 Google 로그인과 같은 제휴 ID 공급업체로 로그인했다면 사용자의 이메일 주소를 ID로 사용하여 Credential 객체를 만들고 setAccountType로 ID 공급업체를 지정합니다.
로그아웃
사용자가 로그아웃하면 CredentialsClient.disableAutoSignIn()를 호출하여 사용자가 즉시 다시 로그인되지 않도록 합니다. 또한 자동 로그인을 사용 중지하면 사용자가 로그인 정보를 다시 입력하지 않고도 직장 계정과 개인 계정 간 또는 공유 기기의 계정 간에 쉽게 전환할 수 있습니다.
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eSmart Lock for Passwords is deprecated; migrate to Credential Manager for enhanced security and user experience with passkeys, passwords, and federated identities.\u003c/p\u003e\n"],["\u003cp\u003eSmart Lock for Passwords integration involves adding the Credentials API to your app's startup and sign-in flow to retrieve and save user credentials.\u003c/p\u003e\n"],["\u003cp\u003eExisting users with saved credentials can experience automatic sign-in, while new users can benefit from pre-filled forms using sign-in hints.\u003c/p\u003e\n"],["\u003cp\u003eEnsure to disable auto-sign-in upon user sign-out to prevent immediate re-authentication and facilitate account switching.\u003c/p\u003e\n"]]],[],null,["# Android integration flow\n\n| **Deprecated:** Smart Lock for Passwords is deprecated. To ensure the continued security and usability of your app, [migrate to\n| Credential Manager](https://developer.android.com/training/sign-in/passkeys/) today. Credential Manager supports passkey, password, and federated identity authentication (such as Sign-in with Google), stronger security, and a more consistent user experience.\n\nTo integrate Smart Lock for Passwords into your Android app, you must add calls\nto the [Credentials API](/android/reference/com/google/android/gms/auth/api/credentials/package-summary)\nto your app's start-up and sign-in flow. The following diagram shows the flow of\na typical Android app that uses Smart Lock for Passwords.\n\nWhile there are many ways to successfully integrate Smart Lock for Passwords,\nand the specifics of an integration depend on the structure and user experience\nof the app, the following flow is recommended for most apps. Apps that use this\nflow have these user experience advantages:\n\n- Existing users of your service that have a single credential saved are immediately signed in, and they will go directly to the signed-in view when they open the app.\n- Users that have multiple credentials saved or that have disabled automatic sign-in need to respond to only one dialog before they go to the app's signed-in view.\n- Users that have no saved credentials or haven't signed up yet can pick their name and email with a single tap and be intelligently sent to either the sign-in or sign-up view, with this information pre-filled.\n- When users sign out, the app ensures they are not automatically signed back in.\n\n[](/static/identity/smartlock-passwords/android/images/smartlock-passwords-flow.png)\n\n### Retrieve credentials\n\n1. When the app starts, if no user is already signed in, call `CredentialsClient.request()`.\n2. If the `Task` is successful, get the user's credentials with `getResult().getCredential()` and use them to sign in.\n3. If the `Task` fails and the exception is an instance of `ResolvableApiException` and `getStatusCode()` returns `RESOLUTION_REQUIRED`, user input is required to pick a credential. Call `startResolutionForResult()` to prompt the user to select a saved account, then call `getParcelableExtra(Credential.EXTRA_KEY)` to get the user's credentials and use them to sign in. If signing in with the retrieved credentials fails because the password is incorrect or the account doesn't exist, delete the credentials from Smart Lock with `CredentialsClient.delete()`.\n\n### Save credentials\n\n4. If the `Task` fails with an `ApiException` and\n `getStatusCode()` returns `SIGN_IN_REQUIRED`, the\n user has no saved credentials and must sign in or sign up manually using\n your current sign-in or sign-up flow. After the user successfully\n completes sign in, you can provide an opportunity for the user to save\n their credentials for future retrieval (step 5).\n\n You can help the user sign in or sign up faster and more\n easily by retrieving sign-in hints, such as the user's email address. The\n user can select the hint and skip typing their credentials. If your app\n requires users to sign in, you might choose to retrieve hints immediately\n after the initial credentials request fails (otherwise, you can wait until\n the user starts the sign-in or sign-up flow).\n 1. Call `CredentialsClient.getHintPickerIntent()` and start the intent to prompt the user to select an account, then call `getParcelableExtra(Credential.EXTRA_KEY)` to get the sign-in hint.\n 2. If the user ID of the hint matches an existing user, pre-fill the sign-in form with it and let the user enter the password to sign in.\n 3. If the user ID of the hint doesn't match an existing user, pre-fill the sign-up form with the user's ID and name, and let the user create a new account.\n5. After the user successfully signs in or creates an account, save the user\n ID and password with `CredentialsClient.save()`.\n\n If the user signed in with a federated identity provider such as Google\n Sign-In, create the `Credential` object with the user's email\n address as the ID and specify the identity provider with\n `setAccountType`.\n\n### Sign out\n\n6. When the user signs out, call `CredentialsClient.disableAutoSignIn()` to prevent the user from being immediately signed back in. Disabling auto-sign-in also enables users to switch between accounts easily---for example, between work and personal accounts, or between accounts on shared devices---without having to re-enter their sign-in information.\n\nReady to integrate Smart Lock for Passwords into your app?\n[Get started](/identity/smartlock-passwords/android/get-started)."]]