import requests
# Endpoint URL for Fyers API
url = "https://api.fyers.in/v1/oauth/token"
# Payload for the POST request
payload = {
"appId": "xxxxxxxxxx", # Replace with your actual App ID
"secretId": "xxxxxxxxx", # Replace with your Secret ID
"code": xxxxxxxxxxxxxxxxxxxxxxxxxx
}
# Headers
headers = {
"Content-Type": "application/json"
}
try:
# Sending POST request
response = requests.post(url, json=payload, headers=headers)
# Checking the status code
if response.status_code == 200:
print("Access Token Response:")
print(response.json()) # Print the access token and other details
else:
print(f"Error: {response.status_code}")
print(response.text) # Print the error details
except Exception as e:
print("An error occurred:", e)