Skip to content

Instantly share code, notes, and snippets.

@justindra
Created January 20, 2021 03:46
Show Gist options
  • Save justindra/05f6e586c5f993293c4ef4c3b6afcf09 to your computer and use it in GitHub Desktop.
Save justindra/05f6e586c5f993293c4ef4c3b6afcf09 to your computer and use it in GitHub Desktop.
Auth0-Authorizer
// Expired Token Gateway Response
new GatewayResponse(this, 'ExpiredTokenGatewayResponse', {
restApi: api,
type: ResponseType.EXPIRED_TOKEN,
statusCode: '401',
templates: {
'application/json': JSON.stringify({
message: 'Provided token is expired',
}),
},
});
// Unauthenticated Gateway Response
new GatewayResponse(this, 'UnauthenticatedGatewayResponse', {
restApi: api,
type: ResponseType.UNAUTHORIZED,
statusCode: '401',
templates: {
'application/json': JSON.stringify({
message: '$context.error.message',
}),
},
});
// Unauthorized Gateway Response
new GatewayResponse(this, 'UnauthorizedGatewayResponse', {
restApi: api,
type: ResponseType.ACCESS_DENIED,
statusCode: '403',
templates: {
'application/json': JSON.stringify({
message: '$context.authorizer.errorMessage',
}),
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment