I went through the FAQ, I get an error 403. I am entering the request token within a minute, have tried in multiple times and ensured that I am entering correct details. I have a question regarding the subscription too, is it possible to get api key and secret without amount getting deducted from my kite trading app?
# Generate login URL and open it in a browser login_url = kite.login_url() print(f"Login URL: {login_url}")
# Open the login URL in the browser webbrowser.open(login_url)
# Prompt the user to enter the request token request_token = input("Enter the request token: ").strip()
# Debugging: print the request token to ensure it's correct print(f"Request Token: {request_token}")
try: # Generate access token using the request token and API secret data = kite.generate_session(request_token, api_secret) access_token = data["access_token"] print(f"Access Token: {access_token}")
# Initialize the KiteConnect object with the access token kite.set_access_token(access_token)
# Make API calls profile = kite.profile() print(profile) except Exception as e: print(f"Error: {e}")
Go through the login FAQs here.
from kiteconnect import KiteConnect
import webbrowser
api_key = " "
api_secret = " "
# Initialize KiteConnect
kite = KiteConnect(api_key=api_key)
# Generate login URL and open it in a browser
login_url = kite.login_url()
print(f"Login URL: {login_url}")
# Open the login URL in the browser
webbrowser.open(login_url)
# Prompt the user to enter the request token
request_token = input("Enter the request token: ").strip()
# Debugging: print the request token to ensure it's correct
print(f"Request Token: {request_token}")
try:
# Generate access token using the request token and API secret
data = kite.generate_session(request_token, api_secret)
access_token = data["access_token"]
print(f"Access Token: {access_token}")
# Initialize the KiteConnect object with the access token
kite.set_access_token(access_token)
# Make API calls
profile = kite.profile()
print(profile)
except Exception as e:
print(f"Error: {e}")