skip to Main Content

I have activated my app after getting approval of my Twitter developer account. I am trying to get twitter account associated with an email/phone number using Twitter Api.
It works perfect with params like screen_name,user_id but while trying email or phone number as a param the

Response says :

Could Not Authenticate you

Code is

import requests

url = "https://api.twitter.com/1.1/users/lookup.json?map=true&phone=1234567890"
payload = {}
headers = {
  'Authorization': 'OAuth realm="http%3A%2F%2Fapi.twitter.com",oauth_consumer_key="<consumer_key>",oauth_token="<outh_token>",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1595318479",oauth_nonce="<nonce>",oauth_version="1.0",oauth_signature="<sig>"'
}

response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))

Response :

{
    "errors": [
        {
            "code": 32,
            "message": "Could not authenticate you."
        }
    ]
}

What are the reasons and suggestions on this ?

Will appreciate the positive feedback.

2

Answers


  1. Have you tried using dynamic values generation for header like nonce generation, Timestamp, base_url according to query paramters?

    Login or Signup to reply.
  2. It is not possible to use email or phone number as query parameters on the Twitter API. This is not supported as a feature in the API. See the documentation for supported parameters on users/lookup and users/search.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search