Coder Social home page Coder Social logo

sms-node.js's Introduction

SMS Verification for Android - Server for Node.js

This sample project demonstrates how to use Twilio's SMS Messaging APIs to verify Android application user's phone numbers. This application supports the SMS Retriever API from Google.

You'll also need to have an Android application that you configure to use these URLs to verify phone numbers.

Configure the sample application

To run the application, you'll need to gather your Twilio account credentials and configure them in a file named .env. To create this file from an example template, do the following in your Terminal.

cp .env.example .env

Open .env in your favorite text editor and configure the following values. You will need all of these values before you continue.

Config Value Description
TWILIO_ACCOUNT_SID Your primary Twilio account identifier - find this in the console here.
TWILIO_API_KEY Used to authenticate - generate one here.
TWILIO_API_SECRET Used to authenticate - just like the above, you'll get one here.
SENDING_PHONE_NUMBER This phone number will be sending the SMS messages to the Android device. Either use a phone number you purchased through Twilio, or one you have verified with your account.
APP_HASH Matches the Android application to the SMS message - See Google's documentation on how to Compute your app's hash string.
CLIENT_SECRET Matches the Android application to the server - you can set this in the strings.xml file in your Android application. It must match the server's config value. You can also override it in the Settings menu of the app.

A Note on API Keys

When you generate an API key pair at the URLs above, your API Secret will only be shown once - make sure to save this information in a secure location, or possibly your ~/.bash_profile.

Run the sample application

Now that the application is configured, we need to install our dependencies from npm.

npm install

Now we should be all set! Run the application using the npm start command.

npm start

Your application should now be running at http://localhost:3000/.

Check your config values, and then make sure everything looks good.

Running the server with ngrok

Your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like ngrok to send HTTP/HTTPS traffic to a server running on your localhost.

You can also deploy this application to a server, or to a cloud provider such as Google App Engine.

ngrok http 3000

Setting the server for the Android application

You'll need to update the Android application with the URLs from ngrok, if you are running locally. If you've deployed this solution to a server, you can use those URLs.

License

MIT

sms-node.js's People

Contributors

bluesven869 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.