Skip to content

Instantly share code, notes, and snippets.

@NIXKnight
Created April 1, 2024 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NIXKnight/b1d260c2b45392248d0aa80f89b99f6c to your computer and use it in GitHub Desktop.
Save NIXKnight/b1d260c2b45392248d0aa80f89b99f6c to your computer and use it in GitHub Desktop.
Check if a Cloudflare Token is valid by using Cloudflare API
import requests
# Replace 'your_cloudflare_api_token_here' with your actual Cloudflare API token
api_token = "your_cloudflare_api_token_here"
# The URL for the Cloudflare API endpoint to check user details
url = "https://api.cloudflare.com/client/v4/user/tokens/verify"
# The headers including the API token for authentication
headers = {
"Authorization": f"Bearer {api_token}",
"Content-Type": "application/json",
}
# Make the GET request to the Cloudflare API
response = requests.get(url, headers=headers)
print(f"{response.text}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment