3

Is it possible to fetch user's phone number from Twitter Digits callback? I'm using http version and javascript to send SMS with twitter digits.

I only see next information response headers:

 {"oauth_echo_headers":{"X-Verify-Credentials-Authorization":"OAuth oauth_consumer_key=\"gmoaaZhEG88hMQUdpWHnF1IAz\", oauth_nonce=\"3375731039-FmyAQgjhQG9rljUaXO3jBbiryF7dFQHeVL5oxu4gmoaaZhEG88hMQUdpWHnF1IAz1437035638029\", oauth_signature=\"TTbPlgipWdaNCSblfx0qznz%2B2Fc%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1437035638\", oauth_token=\"3375731039-FmyAQgjhQG9rljUaXO3jBbiryF7dFQHeVL5oxu4\", oauth_version=\"1.0\"","X-Auth-Service-Provider":"https://api.digits.com/1.1/sdk/account.json"}}
Vnuuk
  • 6,177
  • 12
  • 40
  • 53

2 Answers2

1

Once you receive the credentials authorization header, you can query the server directly to receive attributes from the Digits service. Per the docs:

/* Validate and log user in. */
function onLogin(loginResponse){
  // Send headers to your server and validate user by calling Digits’ API
  var oAuthHeaders = loginResponse.oauth_echo_headers;
  var verifyData = {
    authHeader: oAuthHeaders['X-Verify-Credentials-Authorization'],
    apiUrl: oAuthHeaders['X-Auth-Service-Provider']
  };

  $.post('/verify', verifyData)
    .done(function(){ window.reload(); });
}

You can see a sample of this in action in the Cannonball web demo.

1

May be its late but it can easily be achieved by putting following code wherever you want to fetch phone number:

String phone = Digits.getActiveSession().getPhoneNumber();
Dr. Abhishek
  • 158
  • 1
  • 11