Skip to content

Instantly share code, notes, and snippets.

@cmj
Last active March 10, 2025 06:03
Show Gist options
  • Select an option

  • Save cmj/627d52e1c32b5dc19d61fc7140ffe6b5 to your computer and use it in GitHub Desktop.

Select an option

Save cmj/627d52e1c32b5dc19d61fc7140ffe6b5 to your computer and use it in GitHub Desktop.
Simple Twitter verify_credentials example
#!/bin/bash
# Test various Bearer tokens in Twitter API verify_credentials/isLoggedIn endpoint
# parameters:
# include_entities
# skip_status
# include_email
auth_token=$1
usage() { echo "$0 auth_token"; exit 1; }
[ "$#" -ne 1 ] && usage
x_csrf_token='00000000000000000000000000000000'
# No longer works 2024-11-19 (returns 404 in imperatrona/twitter-scraper/blob/master/auth.go#L25)
#bearer_token="AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA"
# Both tokens work:
# Low x_rate_limit: 75 (from dimdenGD/OldTwitter/blob/master/scripts/config.js#L3)
#bearer_token='AAAAAAAAAAAAAAAAAAAAAG5LOQEAAAAAbEKsIYYIhrfOQqm4H8u7xcahRkU%3Dz98HKmzbeXdKqBfUDmElcqYl0cmmKY9KdS2UoNIz3Phapgsowi'
# High x_rate_limit: 2000
bearer_token="AAAAAAAAAAAAAAAAAAAAAFQODgEAAAAAVHTp76lzh3rFzcHbmHVvQxYYpTw%3DckAlMINMjmCwxUcaXbAN4XqJVdgMJaHqNOFgPMK0zN1qLqLQCF"
curl -s \
-H "Authorization: Bearer ${bearer_token}" \
-H "User-Agent: TwitterAndroid/10.21.1" \
-H "X-Csrf-Token: ${x_csrf_token}" \
-H "Cookie: ct0=${x_csrf_token}; auth_token=${auth_token}" \
'https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true' |
jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment