[AWS] Solve Error: No PEM start marker "b'-----BEGIN PRIVATE KEY-----'" found
AWS Lambda allows you to write customized authorizer for the API gateway, here is the video for Secure your API Gateway with Lambda Authorizer | Step by Step AWS Tutorial.
We can use Firebase to provide the token for our customized authorizer to validate, and use third-party jwt validation library, e.g. python-jose
, like the following line:
decoded = jwt.decode(token, key, algorithms=[
"RS256"], audience="my-development", options={"verify_exp": False})
If you get the following error:
No PEM start marker "b'-----BEGIN PRIVATE KEY-----'" found
Please try to add .encode('ascii')
for the key you provide, like the following line:
decoded = jwt.decode(token, key.encode('ascii'), algorithms=[
"RS256"], audience="my-development", options={"verify_exp": False})
References:
Secure your API Gateway with Lambda Authorizer | Step by Step AWS Tutorial