PKCE verification failed - JS localhost

SOLVED
Go to solution
RyanV806
Campaign Collaborator
0 Votes

I've been trying to build a local app that can access the API, so I can build specific email reports. I'm able to get an authorization code, but once I make a POST request to the Access Token endpoint, I get  '{"error":"invalid_grant","error_description":"PKCE verification failed."}'

 

I have double-checked that the verification code and its hash "match". I'm using Axios for HTTP calls.

 

Could this be a CORS issue?

1 ACCEPTED SOLUTION
RyanV806
Campaign Collaborator
0 Votes

Thanks to the Dev team for helping me pinpoint my issues. I am using JS and AXIOS.

 

Turns out my issue was my code verifier and the code challenge. The code verifier was too long (only needs to be 43-125 characters long) and my code challenge was not matching up with the verifier.

 

I fixed it by:

1) adjusting my code verifier, so it only produced a code within the required limits

2) moving the authorizationURL constructor out of the *main function

3) used async/await for the functions that generated the code challenge and the authorizationURL constructor

 

I could go into more detail about this if anyone needs this in the future.

Example of how my program works:

 

function generateVerifier(){};

async function generateChallenge(){};

async function generateAuthorizationURL(){};

 

//*main function

async function initiateAuthorization(){

       generateVerifier();

       await generateChallenge();

       await generateAuthorizationURL();

};

View solution in original post

2 REPLIES 2
Courtney_E
Employee
0 Votes

Hello RyanV806,

 

Thank you for reaching out to Constant Contact API Developer Support. My team is here to assist outside software developers with questions about building into Constant Contact's API.

 

Please feel free to reach out to our team directly/securely via email at webservices@constantcontact.com and reference case #31236730 with the following information so that we can better assist you:

 

Please provide us with the API key that you are using to make the request, the full request(s) where you are receiving the response error (including URL, headers, timestamp, and request body), and the full response body so that we can so that we can better assist you in identifying the root cause of the issue.

 

Please have a look and let us know if you have any other questions!


Regards,

Courtney E.
Tier II API Support Engineer

Did I answer your question?
If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.
RyanV806
Campaign Collaborator
0 Votes

Thanks to the Dev team for helping me pinpoint my issues. I am using JS and AXIOS.

 

Turns out my issue was my code verifier and the code challenge. The code verifier was too long (only needs to be 43-125 characters long) and my code challenge was not matching up with the verifier.

 

I fixed it by:

1) adjusting my code verifier, so it only produced a code within the required limits

2) moving the authorizationURL constructor out of the *main function

3) used async/await for the functions that generated the code challenge and the authorizationURL constructor

 

I could go into more detail about this if anyone needs this in the future.

Example of how my program works:

 

function generateVerifier(){};

async function generateChallenge(){};

async function generateAuthorizationURL(){};

 

//*main function

async function initiateAuthorization(){

       generateVerifier();

       await generateChallenge();

       await generateAuthorizationURL();

};

Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up