Need help with login/authentication

I am new to API programming, and trying to see order list using this code snippet

from dhanhq import dhanhq

client_id = "1103****"
access_token = "ey*****"

dhan = dhanhq("client_id","access_token")

print(dhan.get_order_list())

I copied client_id and access_token carefully but it ends up in error like this. I also tried creating a new token but in vain.

{'status': 'failure', 'remarks': {'error_code': 'DH-901', 'error_type': 'Invalid_Authentication', 'error_message': 'Client ID or user generated access token is invalid or expired.'}, 'data': {'errorType': 'Invalid_Authentication', 'errorCode': 'DH-901', 'errorMessage': 'Client ID or user generated access token is invalid or expired.'}}

Could someone please help me with this? @Dhan

Hello @Mukul1

Over here, you are doing a simple python mistake, where you have added client_id as access_token as constants instead of variables.

from dhanhq import dhanhq

client_id = "1103****"
access_token = "ey*****"

dhan = dhanhq(client_id,access_token)

print(dhan.get_order_list())

This should help you get started.

1 Like

Thanks, it works fine. Silly mistake.

1 Like