Stay organized with collections
Save and categorize content based on your preferences.
SmsRetriever
contains two APIs, the SMS Retriever API and the SMS User Consent API, that provide access to Google services that help you retrieve SMS messages directed to your app, without having to ask for android.permission.READ_SMS
or android.permission.RECEIVE_SMS
. The SmsCodeRetriever
is for autofill services and browser apps to retrieve SMS-based verification codes.
Many apps use phone numbers to verify the identity of a user. The app sends an SMS message containing an OTP (One Time Passcode) to the user, who then enters the OTP from the received SMS message to prove ownership of the phone number.
In Android, to provide a streamlined UX, an app may request the SMS read permission, and retrieve the OTP automatically. This is problematic since this permission allows the app to read other SMS messages which may contain the user's private information. Also, the latest Play Store policy changes restrict access to SMS messages.
The SMS Retriever API solves this problem by providing app developers a way to automatically retrieve only the SMS directed to the app without asking for the SMS read permission or gaining the ability to read any other SMS messages on the device.
The SMS User Consent API complements the SMS Retriever API by allowing an app to prompt the user to grant access to the content of the next SMS message that contains an OTP. When a user gives consent, the app will then have access to the entire message body to automatically complete SMS verification.
The SMS Retriever API completely automates the SMS-based OTP verification process for the user. However, there are situations where you don’t control the format of the SMS message and as a result cannot use the SMS Retriever API. In these situations, you can use the SMS User Consent API to streamline the process.
With the SMS Code Autofill API, a user-designated autofill service can retrieve the SMS verification codes from the SMS inbox or new incoming SMS messages, then fill in this code for a user to complete any SMS verification requests in a user app. For browser apps, you can achieve this by using the SMS Code Browser API.
Refer to the SMS Retriever Guide
for more details.
Annotations
Permission states for the current user-designated autofill service.
Interfaces
Classes
IncomingCallRetrieverRequest
|
Request for initiating incoming call retriever API for phone number verification.
|
IncomingCallRetrieverResponse
|
A response object representing the outcome of a incoming call verification.
|
SmsCodeRetriever
|
SmsCodeRetriever
is a variant of SmsRetriever
, and it provides access to Google services that help you retrieve SMS verification codes sent to the user's device, without having to ask for android.permission.READ_SMS
or android.permission.RECEIVE_SMS
.
|
SmsRetriever
|
SmsRetriever
provides access to Google services that help you retrieve SMS messages sent to your app without having to ask for android.permission.READ_SMS
or android.permission.RECEIVE_SMS
.
|
SmsRetrieverClient
|
The main entry point for interacting with SmsRetriever
.
|
SmsRetrieverStatusCodes
|
SMS Retriever specific status codes, for use in getStatusCode
.
|
IncomingCallRetriever
|
Entry point for developers to instantiate incoming call retriever API client.
|
IncomingCallRetrieverStatusCodes
|
Incoming call verification specific status codes.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eSmsRetriever\u003c/code\u003e enables apps to retrieve SMS messages, including verification codes, without needing sensitive SMS permissions.\u003c/p\u003e\n"],["\u003cp\u003eIt offers two main APIs: SMS Retriever API for automatic retrieval and SMS User Consent API for user-approved access to specific messages.\u003c/p\u003e\n"],["\u003cp\u003eThe SMS Code Autofill and Browser APIs allow autofill services and browser apps to retrieve and fill in SMS verification codes.\u003c/p\u003e\n"],["\u003cp\u003eThis approach enhances user privacy and streamlines the verification process while complying with Play Store policies.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can learn more by referring to the SMS Retriever Guide.\u003c/p\u003e\n"]]],[],null,["# com.google.android.gms.auth.api.phone\n=====================================\n\n[Kotlin](/android/reference/kotlin/com/google/android/gms/auth/api/phone/package-summary \"View this page in Kotlin\") \\|Java \n\n`SmsRetriever` contains two APIs, the SMS Retriever API and the SMS User Consent API, that provide access to Google services that help you retrieve SMS messages directed to your app, without having to ask for `android.permission.READ_SMS` or `\nandroid.permission.RECEIVE_SMS`. The `SmsCodeRetriever` is for autofill services and browser apps to retrieve SMS-based verification codes.\n\nMany apps use phone numbers to verify the identity of a user. The app sends an SMS message containing an OTP (One Time Passcode) to the user, who then enters the OTP from the received SMS message to prove ownership of the phone number.\n\nIn Android, to provide a streamlined UX, an app may request the SMS read permission, and retrieve the OTP automatically. This is problematic since this permission allows the app to read other SMS messages which may contain the user's private information. Also, the latest Play Store policy changes restrict access to SMS messages.\n\nThe SMS Retriever API solves this problem by providing app developers a way to automatically retrieve only the SMS directed to the app without asking for the SMS read permission or gaining the ability to read any other SMS messages on the device.\n\nThe SMS User Consent API complements the SMS Retriever API by allowing an app to prompt the user to grant access to the content of the next SMS message that contains an OTP. When a user gives consent, the app will then have access to the entire message body to automatically complete SMS verification.\n\nThe SMS Retriever API completely automates the SMS-based OTP verification process for the user. However, there are situations where you don't control the format of the SMS message and as a result cannot use the SMS Retriever API. In these situations, you can use the SMS User Consent API to streamline the process.\n\nWith the SMS Code Autofill API, a user-designated autofill service can retrieve the SMS verification codes from the SMS inbox or new incoming SMS messages, then fill in this code for a user to complete any SMS verification requests in a user app. For browser apps, you can achieve this by using the SMS Code Browser API.\n\nRefer to the [SMS Retriever Guide](https://developers.google.com/identity/sms-retriever/) for more details.\n\nAnnotations\n-----------\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|\n| [SmsCodeAutofillClient.PermissionState](/android/reference/com/google/android/gms/auth/api/phone/SmsCodeAutofillClient.PermissionState) | Permission states for the current user-designated autofill service. |\n\nInterfaces\n----------\n\n|---------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|\n| [IncomingCallRetrieverClient](/android/reference/com/google/android/gms/auth/api/phone/IncomingCallRetrieverClient) | A client for developers to instantiate incoming call retriever API. |\n| [SmsCodeAutofillClient](/android/reference/com/google/android/gms/auth/api/phone/SmsCodeAutofillClient) | The interface for interacting with the SMS Code Autofill API. |\n| [SmsCodeBrowserClient](/android/reference/com/google/android/gms/auth/api/phone/SmsCodeBrowserClient) | The interface for interacting with the SMS Code Browser API. |\n| [SmsRetrieverApi](/android/reference/com/google/android/gms/auth/api/phone/SmsRetrieverApi) | API interface for `SmsRetriever`. |\n\nClasses\n-------\n\n|-------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [IncomingCallRetrieverRequest](/android/reference/com/google/android/gms/auth/api/phone/IncomingCallRetrieverRequest) | Request for initiating incoming call retriever API for phone number verification. |\n| [IncomingCallRetrieverResponse](/android/reference/com/google/android/gms/auth/api/phone/IncomingCallRetrieverResponse) | A response object representing the outcome of a incoming call verification. |\n| [SmsCodeRetriever](/android/reference/com/google/android/gms/auth/api/phone/SmsCodeRetriever) | `SmsCodeRetriever` is a variant of [SmsRetriever](/android/reference/com/google/android/gms/auth/api/phone/SmsRetriever), and it provides access to Google services that help you retrieve SMS verification codes sent to the user's device, without having to ask for `android.permission.READ_SMS` or `android.permission.RECEIVE_SMS`. |\n| [SmsRetriever](/android/reference/com/google/android/gms/auth/api/phone/SmsRetriever) | `SmsRetriever` provides access to Google services that help you retrieve SMS messages sent to your app without having to ask for `android.permission.READ_SMS` or ` android.permission.RECEIVE_SMS`. |\n| [SmsRetrieverClient](/android/reference/com/google/android/gms/auth/api/phone/SmsRetrieverClient) | The main entry point for interacting with `SmsRetriever`. |\n| [SmsRetrieverStatusCodes](/android/reference/com/google/android/gms/auth/api/phone/SmsRetrieverStatusCodes) | SMS Retriever specific status codes, for use in [getStatusCode](/android/reference/com/google/android/gms/common/api/Status#getStatusCode()). |\n| [IncomingCallRetriever](/android/reference/com/google/android/gms/auth/api/phone/IncomingCallRetriever) | Entry point for developers to instantiate incoming call retriever API client. |\n| [IncomingCallRetrieverStatusCodes](/android/reference/com/google/android/gms/auth/api/phone/IncomingCallRetrieverStatusCodes) | Incoming call verification specific status codes. |"]]