Hello fellow developers, I'm working my wy through...
# help
a
Hello fellow developers, I'm working my wy through the notes app example on serverless-stack.com and for some reason I'm not able to test the users authentication (https://serverless-stack.com/chapters/test-the-apis.html). I'm always getting a 500. I've added some logging output and could narrow the problem down - apparently the event.requestContext.identity object is not populated, the key cognitoIdentityId is null. I double checked every step in the tutorial so far and now I'm out of ideas. Can anyone point me into the right direction?
This is the console output
Copy code
Authenticating with User Pool
Getting temporary credentials
Making API request
{
  status: 500,
  statusText: 'Internal Server Error',
  data: {
    error: 'One or more parameter values were invalid: Type mismatch for key userid expected: S actual: NULL'
  }
}
f
Hey @Alfred Brose, if you go into your API Gateway console, can you check if the API you created is a REST type or an HTTP type?
j
Hmm from this error message it sounds like a DynamoDB error. The guide uses
userId
instead of
userid
. Just make sure that’s consistent in your code.
a
@Jay yes, i named the field differently by mistake, but in my app it's consistent. The issue is that the value of "event.requestContext.identity.cognitoIdentityId" is null, so yes the error comes from DynamoDB but the reason is the null-Value.
@Frank the type is REST:
I've published the source code for this demo project at https://github.com/abrose/serverless-stack-api
This ist the requestContext content as printed in the logs
Ok, now I'm feeling dumb. I've edited the serverless.yml and added the authorizer part but for some reason did not save it. The Authorization on the Api Gateway endpoints was still set to "None". After saving the serverless.yml properly and redeploying the stack everything works as expected
Thank you guys!
j
Glad you figured it out.