그런 다음 CredentialsClient.save()를 호출하여 사용자의
사용자 인증 정보를 제공합니다 CredentialsClient.save() 호출이 즉시 처리되지 않은 경우
사용자 인증 정보가 새 인증일 수 있으며, 이 경우 사용자가 새 사용자 인증 정보를 확인해야 합니다.
저장합니다. 다음을 사용하여 ResolvableApiException를 해결합니다.
startResolutionForResult(): 사용자에게 확인 요청 메시지를 표시합니다.
사용자가 사용자 인증 정보를 저장하지 않기로 선택하면 사용자에게 사용자 인증 정보를 저장하라는 메시지가 다시 표시되지 않습니다.
앱의 사용자 인증 정보를 저장합니다. 만약
사용자가 선택 해제하면 CredentialsClient.save() 결과에
CANCELED의 상태 코드입니다. 사용자는 나중에 Google
설정 앱의 비밀번호 대용 Smart Lock 섹션에 있습니다. 사용자가 사용 설정해야 합니다.
사용자 인증 정보 저장이 표시되면 모든 계정에 사용자 인증 정보를 저장하라는 메시지가 표시됩니다.
mCredentialsClient.save(credential).addOnCompleteListener(newOnCompleteListener<Void>(){@OverridepublicvoidonComplete(@NonNullTask<Void>task){if(task.isSuccessful()){Log.d(TAG,"SAVE: OK");Toast.makeText(activity,"Credentials saved",Toast.LENGTH_SHORT).show();return;}Exceptione=task.getException();if(einstanceofResolvableApiException){// Try to resolve the save request. This will prompt the user if// the credential is new.ResolvableApiExceptionrae=(ResolvableApiException)e;try{rae.startResolutionForResult(this,RC_SAVE);}catch(IntentSender.SendIntentExceptionexception){// Could not resolve the requestLog.e(TAG,"Failed to send resolution.",exception);Toast.makeText(activity,"Save failed",Toast.LENGTH_SHORT).show();}}else{// Request has no resolutionToast.makeText(activity,"Save failed",Toast.LENGTH_SHORT).show();}}});</pre>
@OverridepublicvoidonActivityResult(intrequestCode,intresultCode,Intentdata){super.onActivityResult(requestCode,resultCode,data);// ...if(requestCode==RC_SAVE){if(resultCode==RESULT_OK){Log.d(TAG,"SAVE: OK");Toast.makeText(this,"Credentials saved",Toast.LENGTH_SHORT).show();}else{Log.e(TAG,"SAVE: Canceled by user");}}// ...}
Android O를 실행하는 기기에서 Smart Lock을 사용하여 비밀번호 사용자 인증 정보를 저장하는 경우
이상의 경우 Smart Lock은 자체 기능 대신 기본 자동 완성 확인 대화상자를 사용합니다.
가능한 한 자주 사용합니다. (참고:
Google은 비밀번호 대용 Smart Lock과 양방향으로 공유됩니다.)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eSmart Lock for Passwords is deprecated; migrate to Credential Manager for enhanced security and user experience with passkey, password, and federated identity support.\u003c/p\u003e\n"],["\u003cp\u003eStore user credentials after sign-in, account creation, or password changes to enable automated authentication in your app using Credential Manager.\u003c/p\u003e\n"],["\u003cp\u003eCreate \u003ccode\u003eCredential\u003c/code\u003e objects with user sign-in information, including email, password (securely), account type, and profile details, before saving them with \u003ccode\u003eCredentialsClient.save()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eHandle user confirmation for new credentials using \u003ccode\u003eResolvableApiException\u003c/code\u003e and \u003ccode\u003estartResolutionForResult()\u003c/code\u003e to ensure smooth credential saving.\u003c/p\u003e\n"],["\u003cp\u003eRetrieve stored credentials using \u003ccode\u003eCredentialsClient.request()\u003c/code\u003e for seamless user authentication within your app.\u003c/p\u003e\n"]]],[],null,["# Store a user's credentials\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\nAfter users successfully sign in, create accounts, or change passwords, allow\nthem to store their credentials to automate future authentication in your app.\n\nBefore you begin\n----------------\n\n[Configure an Android Studio project](/identity/smartlock-passwords/android/get-started).\n\nStore credentials\n-----------------\n\nCreate a `Credential` object containing a user's sign-in information. For\nexample, to let users store their credentials after successfully signing in with\ntheir passwords: \n\n Credential credential = new Credential.Builder(email)\n .setPassword(password) // Important: only store passwords in this field.\n // Android autofill uses this value to complete\n // sign-in forms, so repurposing this field will\n // likely cause errors.\n .build();\n\nOr, for example, after users successfully\n[sign in with their Google account](/identity/sign-in/android/people): \n\n GoogleSignInAccount gsa = signInTask.getResult();\n Credential credential = new Credential.Builder(gsa.getEmail())\n .setAccountType(IdentityProviders.GOOGLE)\n .setName(gsa.getDisplayName())\n .setProfilePictureUri(gsa.getPhotoUrl())\n .build();\n\nThen, call [`CredentialsClient.save()`](/android/reference/com/google/android/gms/auth/api/credentials/CredentialsClient#save(com.google.android.gms.auth.api.credentials.Credential)) to save users'\ncredentials. If the call to `CredentialsClient.save()` is not immediately\nsuccessful, the credentials might be new, in which case the user must confirm\nthe save request. Resolve the `ResolvableApiException` with\n`startResolutionForResult()` to prompt the user for confirmation.\n\nIf the user chooses not to save credentials, the user won't be prompted again to\nsave any account's credentials for the app. If you call\n`CredentialsClient.save()` after a user has opted out, its result will have a\nstatus code of [`CANCELED`](/android/reference/com/google/android/gms/common/api/CommonStatusCodes#CANCELED). The user can opt in later from the Google\nSettings app, in the Smart Lock for Passwords section. The user must enable\ncredential saving for all accounts to be prompted to save credentials next time. \n\n mCredentialsClient.save(credential).addOnCompleteListener(\n new OnCompleteListener\u003cVoid\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cVoid\u003e task) {\n if (task.isSuccessful()) {\n Log.d(TAG, \"SAVE: OK\");\n Toast.makeText(activity, \"Credentials saved\", Toast.LENGTH_SHORT).show();\n return;\n }\n\n Exception e = task.getException();\n if (e instanceof ResolvableApiException) {\n // Try to resolve the save request. This will prompt the user if\n // the credential is new.\n ResolvableApiException rae = (ResolvableApiException) e;\n try {\n rae.startResolutionForResult(this, RC_SAVE);\n } catch (IntentSender.SendIntentException exception) {\n // Could not resolve the request\n Log.e(TAG, \"Failed to send resolution.\", exception);\n Toast.makeText(activity, \"Save failed\", Toast.LENGTH_SHORT).show();\n }\n } else {\n // Request has no resolution\n Toast.makeText(activity, \"Save failed\", Toast.LENGTH_SHORT).show();\n }\n }\n });\u003c/pre\u003e\n\n @Override\n public void onActivityResult(int requestCode, int resultCode, Intent data) {\n super.onActivityResult(requestCode, resultCode, data);\n\n // ...\n\n if (requestCode == RC_SAVE) {\n if (resultCode == RESULT_OK) {\n Log.d(TAG, \"SAVE: OK\");\n Toast.makeText(this, \"Credentials saved\", Toast.LENGTH_SHORT).show();\n } else {\n Log.e(TAG, \"SAVE: Canceled by user\");\n }\n }\n\n // ...\n\n }\n\nAfter storing credentials, retrieve them by calling\n[`CredentialsClient.request()`](/android/reference/com/google/android/gms/auth/api/credentials/CredentialsClient#request(com.google.android.gms.auth.api.credentials.CredentialRequest)).\n\nTargeting Android O and above\n-----------------------------\n\nWhen you save password credentials using Smart Lock on devices running Android O\nor newer, Smart Lock uses the native autofill confirmation dialog over its own\ndialog whenever possible. (Note that credentials saved using Autofill with\nGoogle are bi-directionally shared with Smart Lock for Passwords.)"]]