Dhan HQ API related issues

I am getting an error in python while connecting to API.

"The token was expected to have 3 parts , but go…

Can anyone help

Hi @bsjhala

This error message comes when you have not pasted the token in full length.

Please make sure you are using active & correct Access Token. Generate token from web.dhan.co > My Profile > DhanHQ Trading APIs & Access > Access Token.

You can try and hit any GET API with your token at api.dhan.co with curl commands, to check whether token is active & working.

i copied from the profile and pasted in a variable.
Its not working in python…
But,I checked on api.dhan.co and pasted there,Its working there.

what can be issued, i checked thrice, access token length is correct.

issue resolved.

problem was due to wrong variable name

Help i am getting same error

Hello @Pranav05

Welcome to Dhan Community!

If you are also using Python and getting the same error then do check for the Access token that you have pasted along with the variable name. Let us know if you are still getting this error.

sir i am still gatting error


If the error is still the same, this means that the access token is not being entered correctly. Can you confirm if you are using Dhan Python library? or any other custom code?

Hello @amitbalagi

Welcome to Dhan community!

This looks like a token issue. Are you using a valid token and passing the same successfully in your code? You can add more information here with a code snippet to help community members debug the same.

same error what wrong variable name you put ?

Hello @shrivallabh

Welcome to Dhan Community!

Are you also facing the same error? Kindly check the access token added as suggested in thread above.

Hello Im also getting the same error. its my first program. pls help

Hello @abrsetti

Welcome to Dhan Community!

Sure, can you send code snippet where you are adding the token? Or what is the error that you are getting?

Lol, I found what this error is and why so many people are facing it.

The demo code from dhan has this line:

access_token = “xxxxxxxxxxxx”
dhan = dhanhq(“client_id”,“access_token”)

So, no matter what you put in the access_token variable, the actual value being passed is the literal string “access_token”. Remove the quotes from the second line and it should work.

1 Like