-
Notifications
You must be signed in to change notification settings - Fork 113
Description
Hello,
I am able to generate an auth_code successfully using the Fyers OAuth login URL, but when I try to exchange the auth_code for an access_token using the API, I consistently receive:
code: -441, message: "invalid grant type"
I have:
• Set a valid HTTPS Redirect URL
• Regenerated my Secret Key
• Used a fresh auth_code
• Matched the redirect URI in both login and token exchange
Please check if my app or account has any restriction on token generation or if there is any change in OAuth requirements.
Regenerate fyers token
from fyers_api import fyersModel
CLIENT_ID = "xxxxxx"
SECRET_KEY = "xxxxxxx"
REDIRECT_URI = "https://wefocusclasses.com/"
RESPONSE_TYPE = "code"
STATE = "state123"
session = fyersModel.SessionModel(
client_id=CLIENT_ID,
secret_key=SECRET_KEY,
redirect_uri=REDIRECT_URI,
response_type=RESPONSE_TYPE,
state=STATE
)
auth_url = session.generate_authcode()
print("\nOpen this URL in Chrome:\n")
print(auth_url)
auth_code = input("\nPaste auth code here: ").strip()
session.set_token(auth_code)
response = session.generate_token()
print("\nFULL RESPONSE FROM FYERS:")