607835 (2) [Avatar] Offline
#1
Working my way through the course, and learning a great deal along the way, but struggling with the above section, I've come to the end of the section but when I try to search for restaurants I get a pop-up stating "message: "Authorization header requires 'Credential' parameter. Authorization header requires 'Signature' parameter. Authorization header requires 'SignedHeaders' parameter. Authorization header requires existence of either a 'X-Amz-Date' or a 'Date' header. Authorization=ey......."

In the Chrome Developer Tools Console I can see the idToken and the session validity is true but I'm getting a 403 back

Any ideas on where I have gone wrong?

Thanks

Jon
Yan Cui (68) [Avatar] Offline
#2
Hi Jon,

That error sounds like the search-restaurants endpoint is configured with AWS_IAM authentication (which is why it's looking for the X-Amz-Date header). I'd have a look at the API Gateway configuration for the search endpoint and see what it's configured with, and then go back to the serverless.yml to make sure the search endpoint is configured correctly.

You can always go to this page to see all the code snapshots at the end of each module if you're stuck.

Cheers,
607835 (2) [Avatar] Offline
#3
Hi Yan,

Thank you for coming back to me so promptly!

I've reviewed my code and compared it to the code you linked to (section 2.7) get-index.js and found that the code in your link is slightly different to the code shown on screen. In 'Securing API endpoints with Cognito User Pools' around 6:29 you update view with the variables in a different order... I changed it to as shown in GitHub and search is now working

Correct order is
let view = {
awsRegion,
cognitoUserPoolId,
cognitoClientId,
dayOfWeek,
restaurants,
searchUrl: `${restaurantsApiRoot}/search`
};

Thanks again for a great course and prompt response.

Jon

UPDATE: It is not the order but my use of single quotes around the searchUrl, I had searchUrl: '${restaurantsApiRoot}/search' where as it should be searchUrl: `${restaurantsApiRoot}/search`