Skip to content

issue in generating access token #41

@kalaramanb-rgb

Description

@kalaramanb-rgb

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:")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions