generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
@ amplify/backend/function/amplifyIdentityBrokerToken/src/index.js
else if (grant_type === "refresh_token") {
var cognitoResponse = await cognitoSP.initiateAuth(params).promise(); // Call Cognito with refresh token to get refreshed id and access tokens
var access_token = cognitoResponse.AuthenticationResult.AccessToken;
var id_token = cognitoResponse.AuthenticationResult.IdToken;
}
The promise of cognitoSP.initiateAuth(params) may throw an error.
IMO, we should add a try catch to properly handle this.
try {
var cognitoResponse = await cognitoSP.initiateAuth(params).promise();
} catch (error) {
const errorBody = {
errorType: error. errorType,
errorMessage: error. errorMessage,
time: error.time,
...
stack: error.stack
}
return {
statusCode: error.statusCode,
body: JSON.stringify(errorBody)
};
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels