Verificación automática de SMS con la API de SMS Retriever
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Con la API de SMS Retriever, puedes realizar una verificación del usuario mediante SMS en tu app para Android de forma automática, sin que este tenga que escribir manualmente códigos de verificación y sin necesidad de permisos adicionales de la app. Cuando implementas la verificación automática por SMS en tu app, el flujo de verificación se ve de la siguiente manera:

- Un usuario inicia la verificación por SMS en tu app. Es posible que tu app le pida al usuario que proporcione un número de teléfono o que use el selector de sugerencia de Smart Lock para contraseñas si no se requirió que se creara la cuenta del usuario.
- Tu aplicación realiza una solicitud al servidor para verificar el número de teléfono del usuario.
Según la información disponible en la base de datos de usuarios, esta solicitud puede incluir el ID del usuario, el número de teléfono del usuario o ambos.
- Al mismo tiempo, tu app llama a la API de SMS Retriever para comenzar a detectar una respuesta de SMS de tu servidor.
- El servidor envía un mensaje SMS al usuario que incluye un código único que se enviará de vuelta al servidor y un hash que identifica la app.
- Cuando el dispositivo del usuario recibe el mensaje SMS, los Servicios de Google Play usan el hash de la app para determinar si el mensaje está destinado a tu app y permite que el texto del mensaje esté disponible en la app mediante la API de SMS Retriever.
- Tu app analiza el código único del texto del mensaje y lo envía de vuelta al servidor.
- El servidor recibe el código único de tu app, verifica el código y, por último, registra que el usuario verificó su cuenta correctamente.
Para implementar la verificación automática de SMS en tu app, consulta las guías para servidores y Android:
Guía para Android
Guía para servidores
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-25 (UTC)
[null,null,["Última actualización: 2025-07-25 (UTC)"],[[["\u003cp\u003eThe SMS Retriever API enables automatic SMS verification in Android apps, eliminating manual code entry for users.\u003c/p\u003e\n"],["\u003cp\u003eThis API streamlines user verification by having your app listen for an SMS message containing a one-time code, sent by your server after a verification request.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Play services identifies the incoming SMS message as intended for your app using an app hash included in the message, ensuring secure delivery of the verification code.\u003c/p\u003e\n"],["\u003cp\u003eThe SMS Retriever API enhances user experience and security by automating verification without requiring extra app permissions.\u003c/p\u003e\n"]]],[],null,["# Automatic SMS Verification with the SMS Retriever API\n\nWith the SMS Retriever API, you can perform SMS-based user verification in your\nAndroid app automatically, without requiring the user to manually type\nverification codes, and without requiring any extra app permissions. When you\nimplement automatic SMS verification in your app, the verification flow looks\nlike this:\n\n[](/static/identity/sms-retriever/flow-overview.png)\n\n1. A user initiates SMS verification in your app. Your app might prompt the user to provide a phone number or use the [Smart Lock for Passwords hint selector](/identity/smartlock-passwords/android/retrieve-hints) if that information wasn't required to create the user's account.\n2. Your app makes a request to your server to verify the user's phone number. Depending on what information is available in your user database, this request might include the user's ID, the user's phone number, or both.\n3. At the same time, your app calls the SMS Retriever API to begin listening for an SMS response from your server.\n4. Your server sends an SMS message to the user that includes a one-time code to be sent back to your server, and a hash that identifies your app.\n5. When the user's device receives the SMS message, Google Play services uses the app hash to determine that the message is intended for your app, and makes the message text available to your app through the SMS Retriever API.\n6. Your app parses out the one-time code from the message text and sends it back to your server.\n7. Your server receives the one-time code from your app, verifies the code, and finally records that the user has successfully verified their account.\n\nTo implement automatic SMS verification in your app, see the Android and server\nguides:\n\n[Android Guide](/identity/sms-retriever/request)\n[Server Guide](/identity/sms-retriever/verify)"]]