Kotak-Neo / kotak-neo-api

100 stars 86 forks source link

Sandbox environment #45

Closed Mclovin-code closed 10 months ago

Mclovin-code commented 11 months ago

Hi, I was trying to access the sandbox environment, I generated the consumer key and secret from the portal but whenever I try to log in, i am left with message, can you help me understand what I am doing wrong

Thanks

consumer_key = 'xxx'
consumer_secret = 'xxx'

from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import pickle
import os.path
import re
import neo_api_client
from neo_api_client import NeoAPI
import time 

def on_message(message):
    print(message)

def on_error(error_message):
    print(error_message)

client = NeoAPI(consumer_key=consumer_key, consumer_secret=consumer_secret, 
        environment='prod', on_message=on_message, on_error=on_error, on_close=None, on_open=None)

after running the above code I got a response like this

{"data": {"access_token": "xxx", "scope": "default", "token_type": "Bearer", "expires_in": 72000}}

The error happens when I try to log in

client.login(mobilenumber="xxx", password="xxx")

Error - Traceback (most recent call last):

File "/var/folders/4x/s72xvc9d2hs6s8jq6vv26d040000gn/T/ipykernel_84175/4286315428.py", line 1, in <cell line: 1> client.login(mobilenumber="xxx", password="xxx")

File "/opt/homebrew/lib/python3.10/site-packages/neo_api_client/neo_api.py", line 120, in login gen_otp = neo_api_client.LoginAPI(self.api_client).generate_otp()

File "/opt/homebrew/lib/python3.10/site-packages/neo_api_client/api/login_api.py", line 86, in generate_otp userId = self.api_client.configuration.extract_userid(self.api_client.configuration.view_token)

File "/opt/homebrew/lib/python3.10/site-packages/neo_api_client/neo_utility.py", line 47, in extract_userid raise ApiValueError(

ApiValueError: View Token hasn't been Generated Kindly Call the Login Function and Try to Generate OTP

Kotak-Neo commented 10 months ago

For getting sandbox access kindly mail to neo.api@kotak.com.