Skip to content

Instantly share code, notes, and snippets.

@cmj
Created December 9, 2025 11:07
Show Gist options
  • Select an option

  • Save cmj/24c9f53dad6fb469e82e149e44210f03 to your computer and use it in GitHub Desktop.

Select an option

Save cmj/24c9f53dad6fb469e82e149e44210f03 to your computer and use it in GitHub Desktop.
verify_credentials example
#!/bin/bash
# Test verify_credentials/isLoggedIn endpoint
usage() { echo "$0 <auth_token>"; exit 1; }; [ -z $1 ] && usage
#. ~/.env-twitter
x_csrf_token=00000000000000000000000000000000
auth_token=$1
bearer_token="AAAAAAAAAAAAAAAAAAAAAFXzAwAAAAAAMHCxpeSDG1gLNLghVe8d74hl6k4%3DRUMF4xAQLsbeBhTSRrCiQpJtxoGWeyHrDb5te2jpGskWDFW82F"
url="https://api.x.com/1.1/account/verify_credentials.json?include_email=true&skip_status=false&include_entities=true"
user_agent=(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
"Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0"
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
"python-requests/2.32.3"
"TwitterAndroid/10.21.1"
"twitterbot/666"
"TwitterAndroid"
)
# only works with TwitterAndroid user-agents 4,6
curl -s "${url}" \
-H "Authorization: Bearer ${bearer_token}" \
-H "User-Agent: ${user_agent[6]}" \
-H "x-csrf-token: ${x_csrf_token}" \
-H "cookie: ct0=${x_csrf_token}; auth_token=${auth_token}" |
jq #tee ~/dev/twitter-auth_tokens/$auth_token-$EPOCHSECONDS | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment