Hi Team,
I am trying to login using the api, but I am receiving the following error:
Traceback (most recent call last):
File “D:/Learning_Development/Python/connect_upstox.py”, line 26, in
profile = client.get_profile()
AttributeError: ‘ApiClient’ object has no attribute ‘get_profile’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:/Learning_Development/Python/connect_upstox.py”, line 28, in
except upstox_client.UpstoxException as e:
AttributeError: module ‘upstox_client’ has no attribute ‘UpstoxException’
Here is the code I am using the access:
import upstox_client
your api key and secret
configuration = upstox_client.Configuration()
configuration.api_key = “my_api_key”
configuration.api_secret = “my_api_secret”
client = upstox_client.ApiClient(configuration)
#api_key = “my_api_key”
#api_secret = “my_api_secret”
Initialize the upstox client
client = upstox_client.ApiClient(configuration)
Step 2: Generate login URL and visit it manually to get the authorization code
#login_url = client.get_login_url()
#print(“Login URL:”, login_url)
After logging in via the URL, you will get an authorization code (manually copy it)
authorization_code = input("Enter the authorization code: ")
Step 3: Get the access token using the authorization code
client.get_access_token(authorization_code)
Get user profile
try:
profile = client.get_profile()
print(profile)
except upstox_client.UpstoxException as e:
print(f"Error: {e}")
Let me know if you need any additional details