Skip to main content

Hi there,

I’m getting the following error when requesting an access token from the authorization code previously generated by Docusign:

{
"error": "invalid_grant"
}

I’ve followed all steps in https://developers.docusign.com/platform/auth/public-authcode-get-token/. I can easily get an authorization code, but when using it to request an access token I get above error. This is the request I do:
POST in https://account-d.docusign.com/oauth/token with:

code=<code returned as query param in the redirect_uri>
grant_type=authorization_code
client_id=<my integration key in development environment>
code_verifier=<my original random string used to calculate the code challenge>

I’ve made sure that the code was generated less than 2 minutes before asking for the access token.

What am I missing?

@dcamarasa 

Confirm that the code was generated with the same integration key you’re using now. Generate a fresh authorization code from scratch (start a new flow) and almost immediately send the token exchange. 


Without seeing your specific call and values it’s difficult to troubleshoot exactly. But ensure that you have base64 encoded the code verifier after hashing it with s256. You might also walk through the video steps and see if you are doing any pieces of it differently:

 

 


Hi ​@JohnSantos, ​@Cassandra.Loewen,

I attach the parameters amb using for the second and third step of above guide:
 

 

And these are the Authentication settings in my account:
 

 


@JohnSantos ​@Cassandra.Loewen could you please tell me what I’m doing wrong here?

 

Thank you


Hi, apologies for the delayed response. From some testing, I believe that the error that you’re getting indicates that the verifier and challenge aren’t matching up. The rest of your settings look right to me. 

When you are generating the challenge, given the starting verifier value R8zFoqs0yey29G71QITZs3dK1YsdIvFNBfO4D1bukBw, what do you end up with? The correct challenge value, given that example verifier, should be RqN6kvc2fJwD-BQG3SzsDfQcX54BxuyuM40alAt8b5M.

You can also use an online PKCE generator tool (such as https://example-app.com/pkce) to simplify this for testing purposes.