Fazi
09/30/2021, 3:30 PMconst api = new Api(this, "Api", {
routes: {
"GET /skills": skillsSyncFunction
},
});
I want to secure these so that the client needs a bearer token before making a request. My access token has the following fields:
{ 'AccessToken': 'eyJ...', 'ExpiresIn': 300, 'TokenType': 'Bearer', 'IdToken': 'eyJ...' }
What would be the correct way to set up auth? I tried this but it failed:
const api = new Api(this, "Api", {
defaultAuthorizationType: ApiAuthorizationType.JWT,
defaultAuthorizer: new HttpUserPoolAuthorizer({
'userPool': env['AWS_USER_POOL'],
'userPoolClient': env['AWS_CLIENT_ID']
}),
routes: {
"GET /skills": skillsSyncFunction
},
});
However this threw an error message:
ApiUserPoolAuthorizer6F4D9292 Caught exception when connecting to <https://cognito-idp.eu-west-2.amazonaws.com/undefined/.well-known/openid-configuration> for issuer <https://cognito-idp.eu-west-2.amazonaws.com/undefined>. Please try again later. Error: Invalid issuer: <https://cognito-idp.eu-west-2.amazonaws.com/undefined>. Issuer must have a valid discovery endpoint ended with '/.well-known/openid-configuration' (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 0000; Proxy: null)
Could someone please guide me on how I could get auth working with API endpoints? Rest seems to all work very wellGarret Harp
09/30/2021, 4:16 PMconst auth = new Auth(this, ...)
const api = new Api(this, "Api", {
defaultAuthorizer: new HttpUserPoolAuthorizer({
userPool: auth.cognitoUserPool,
userPoolClient: auth.cognitoUserPoolClient
}),
...
})
Fazi
10/01/2021, 8:59 AMFazi
10/01/2021, 10:39 AM*const* pool = cognito.UserPool.fromUserPoolId(*this*, 'name', 'id');