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


  • import smartapi # Version 1.3.0
    from smartapi.smartConnect import SmartConnect

    obj=SmartConnect(api_key=MyAPIKey)
    data = angel.generateSession(client_code,password,totp)
    refreshToken= data['data']['refreshToken']
    userProfile= obj.getProfile(refreshToken)
    print(userProfile)

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

    try:
    historicParam = {
    "exchange": "NSE",
    "symboltoken": "3045",
    "interval": "ONE_DAY",
    "fromdate": '2023-04-27 09:00',
    "todate": '2023-04-30 14:00' }
    df = obj.getCandleData(historicParam)
    print (df)
    except Exception as e:
    print(f'Historic Api failed: {e}')

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