Topic 1 Question 431
A developer is troubleshooting an application. The application includes several AWS Lambda functions that invoke an Amazon API Gateway API. The API Gateway's method request is set up to use an Amazon Cognito authorizer for authentication.
All the Lambda functions pass the user ID as part of the Authorization header to the API Gateway API. The API Gateway API returns a 403 status code for all GET requests.
How should the developer resolve this issue?
Modify the client GET request to include a valid API key in the Authorization header.
Modify the client GET request to include a valid token in the Authorization header.
Update the resource policy for the API Gateway API to allow the execute-api:Invoke action.
Modify the client to send an OPTIONS preflight request before the GET request.
ユーザの投票
コメント(4)
Option B is the correct solution, as the client must provide a valid token in the Authorization header for Cognito authorizer to work properly.
👍 1stevesuperdx2024/09/25- 正解だと思う選択肢: B
the answer is B
👍 1YUICH2024/10/09 - 正解だと思う選択肢: B
const apiUrl = 'https://api.example.com/my-resource';
const headers = { 'Authorization':
Bearer ${idToken}, // JWT token 'Content-Type': 'application/json' };fetch(apiUrl, { method: 'GET', headers: headers }) .then(response => { if (!response.ok) { throw new Error('API request failed'); } return response.json(); }) .then(data => console.log(data)) .catch(error => console.log('Error:', error));
👍 1albert_kuo2024/10/09
シャッフルモード