Response: {'success': False, 'message': 'Invalid Token', 'errorCode': 'AG8001', 'data': ''}


  • CLIENT ID : R946011

    I am using the correct api_key and login credentials but getting following error:
    Response: {'success': False, 'message': 'Invalid Token', 'errorCode': 'AG8001', 'data': ''}

    When I run the following code:
    obj = SmartConnect(api_key= api_key)
    data = smartApi.generateSession(username, pwd, totp)
    refreshToken = data['data']['refreshToken']
    res = obj.getProfile(refreshToken)
    params = {
    "exchange": "NSE",
    "symboltoken": "99926000",
    "interval": "ONE_HOUR",
    "fromdate": "2023-09-06 11:15",
    "todate": "2023-09-06 12:00"
    }

    hist_data = obj.getCandleData(params);


  • Hello @coder
    Please add the auth token as well in your code like below
    authToken = data['data']['jwtToken']
    Regards,
    SmartAPI Team