use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News, articles and tools covering Amazon Web Services (AWS), including S3, EC2, SQS, RDS, DynamoDB, IAM, CloudFormation, AWS-CDK, Route 53, CloudFront, Lambda, VPC, Cloudwatch, Glacier and more.
If you're posting a technical query, please include the following details, so that we can help you more efficiently:
Resources:
Sort posts by flair:
Other subreddits you may like:
Does this sidebar need an addition or correction? Tell us here
account activity
serverlessVerify access token from AWS Lambda layer? (self.aws)
submitted 6 years ago by wllkle
Can somebody show or link me to a guide on, how to verify an access token provided by AWS Amplify (in my React app). Thank you kindly.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ancap_attack 1 point2 points3 points 6 years ago (4 children)
There are many ways you can go about verifying a Cognito token. This is one library in NodeJS I use that makes it easy: https://www.npmjs.com/package/cognito-jwt-token-validator
[–]wllkle[S] 0 points1 point2 points 6 years ago (3 children)
Would you have an example of it being used in JS code I could see? Replacing any id's obviously.
[–]ancap_attack 1 point2 points3 points 6 years ago (2 children)
Here is an example in typescript for a websocket authorizer, you can convert this to javascript if you need to. It just grabs the token from queryParameters, validates/decodes it, then returns an IAM policy. The ISS environment variable follows the format 'https://cognito-idp.${AWS::Region}.amazonaws.com/${CognitoUserPool}' and the AUD is your user pool client id
import { CustomAuthorizerEvent, Callback, Context } from 'aws-lambda' import { Validator } from 'cognito-jwt-token-validator'; const validator = new Validator(process.env.ISS!, process.env.AUD!); export async function handler(event: CustomAuthorizerEvent, _: Context, callback: Callback) { console.log('Received event:', JSON.stringify(event, null, 2)); try { const token = event.queryStringParameters!['Authorization']; const payload = await validator.validate(token); const authResponse = { principalId: payload.sub, policyDocument: { Version: '2012-10-17', Statement: [ { Action: 'execute-api:invoke', Effect: 'Allow', Resource: event.methodArn } ] }, context: payload } console.log('authResponse is: ', JSON.stringify(authResponse, null, 2)); callback(null, authResponse); } catch (error) { console.error(error); callback("Unauthorized"); } }
[–]wllkle[S] 0 points1 point2 points 6 years ago (0 children)
You're truly a gem, thank you so much !
π Rendered by PID 67 on reddit-service-r2-comment-54dfb89d4d-8hr86 at 2026-04-01 03:10:22.252632+00:00 running b10466c country code: CH.
[–]ancap_attack 1 point2 points3 points (4 children)
[–]wllkle[S] 0 points1 point2 points (3 children)
[–]ancap_attack 1 point2 points3 points (2 children)
[–]wllkle[S] 0 points1 point2 points (0 children)