Digits Login
Twitter's Digits service provides phone number login via SMS confirmation codes for any web app or mobile app.
Digits for Web
The Digits Javascipt SDK launches a web popup to prompt a user to enter a phone number and an SMS confirmation code.
The page receives OAuth Echo headers which can be posted to a Go server, validated, and used to fetch the user's Digits account. Package gologin
provides Go handlers for Digits which perform these steps correctly.
Getting Started
go get github.com/dghubble/gologin/digits
cd $GOPATH/src/github.com/dghubble/gologin/examples/digits
go get .
Example App
main.go shows an example web app which uses gologin
for Digits to issue a client-side cookie session. For simplicity, no data is persisted.
Get your Digits application's consumer key from the fabric.io dashboard.
Note: Currently a Digits application must be created by making a dummy iOS or Android app via the Fabric iOS Mac App or Android Studio Plugin.
Compile and run main.go
from examples/digits
. Pass the key as an argument to the executable
go run main.go -consumer-key=xx
2015/09/25 21:44:48 Starting Server listening on localhost:8080
or set the DIGITS_CONSUMER_KEY
environment variable.
Here is what the web login flow looks like (showing a mobile browser).
Authorization Flow
-
Clicking the "Login with Digits" button launches the Digits web login popup.
-
User enters a phone number and receives an SMS confirmation number to enter. The page receives OAuth Echo fields and POSTs them to the Go server.
-
The Echo fields are validated, used to obtain the Digits Account
, and provided to the specified success http.Handler
.
-
In this example, that account is read and used to issue the user a signed cookie session.