title: Using AWS Cognito for API Gateway Authorization
body: <p>I am currently using the Hosted Cognito UI with a user pool. By using a domain as set in the pool settings, I can send users to the login screen:</p>
  
  <pre><code>https://&lt;domain&gt;.auth.eu-west-1.amazoncognito.com/login?response_type=code&amp;client_id=&lt;client_id&gt;&amp;redirect_uri=&lt;redirect_uri&gt;
  </code></pre>
  
  <p>Upon successful username/password entry, Cognito now redirects to the url as specified in the pool settings and in the URL above. This points to a /GET in API Gateway which has Authorization enabled via AWS Cognito. However, I am always denied access:</p>
  
  <pre><code>{"message":"Unauthorized"}
  </code></pre>
  
  <p>Note that if I:</p>
  
  <pre><code>curl --header "Authorization: &lt;the authorization token&gt;" https://&lt;the redirect url&gt;
  </code></pre>
  
  <p>then I am authorized and obtain the desired result from API Gateway.</p>
  
  <p>My assumption is that something is wrong in passing the Authorization token from Cognito to API Gateway. My settings are as follows:</p>
  
  <p><strong>API Gateway Settings</strong></p>
  
  <p><strong>/GET Method Request</strong></p>
  
  <pre><code>Authorization: my-cognito-user-pool
  OAuth Scope: None
  Request Validator: Validate query string parameters and headers
  API Key Required: false
  
  *HTTP Request Headers*
  Name: Authorization, Required:N, Caching:N
  </code></pre>
  
  <p><strong>/GET Integration Request</strong></p>
  
  <pre><code>Integration Type: Lambda Function
  Use Lamba Proxy Integration: N
  Lambda Region: eu-west-1
  Lambda Function: my-lambda-function
  Invoke with caller credentials: N (it does not allow me to check this box)
  Use Default Timeout: Y
  
  *HTTP Headers*
  
  Name: Authorization, Mapped From: method.request.header.Authorization, Caching: N
  </code></pre>
  
  <p><strong>Cognito Settings</strong></p>
  
  <p><a href="https://i.stack.imgur.com/d3s6U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d3s6U.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/nWyKv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nWyKv.png" alt="enter image description here"></a></p>
  
  <p>Thank you!!</p>