skip to Main Content

I am trying to integrate the oauth flow in my application.

I am getting a 401 when calling the oauth/request_token endpoint with this error:

"message": "401 - {"errors":[{"code":135,"message":"Timestamp out of bounds."}]}"

This is my authorization header:

"Authorization": "OAuth oauth_callback=http%3A%2F%2F127.0.0.1%3A3000%2Ftwitter%2Foauth_callback,oauth_consumer_key=MYKEY,oauth_nonce=150255341200200,oauth_signature_method=HMAC-SHA1,oauth_timestamp=1502553412002,oauth_version=1.0,oauth_signature=d09f2f2a39e51909442ae6ca717e4aeba7066fda"

I can see in the response header that the server time for Twitter is:“date”: “Sat, 12 Aug 2017 15:56:52 GMT”

If I take my timestamp and convert it to a GMT date I get:

Saturday, August 12, 2017 3:56:52.002 PM

I am not sure why it is considered out of bounds.

2

Answers


  1. The oauth_timestamp should be the number of whole seconds since 1 Jan 1970 00:00:00 UTC.

    Your timestamp is out by a factor of around 1000! It should have been:

    oauth_timestamp=1502553412
    
    Login or Signup to reply.
  2. For timestamp value, please use the below piece of code:

    Math.floor((new Date()).getTime() / 1000);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search