title: AWS Api Gateway mock integration response header mapping, how?
body: <p>I was digging web and kept trying to find what I am missing in the following situation:
  The basic problem I am trying to solve is: when <a href="http://example.com/login?target=http://google.com" rel="nofollow noreferrer">http://example.com/login?target=http://google.com</a> is called, the user is redirected to an OAuth login page with the state referring to the url in the target query param.</p>
  
  <p>So:  <code>http://example.com/login?target=http://google.com</code>
  would be redirected to
  <code>http://authenticator.com/login?type=...&amp;redirect_uri=...&amp;client_id=...&amp;state=http://google.com</code></p>
  
  <p>I could do this with Lambda, but I felt it is unnecessary and API Gateway could be used solely.</p>
  
  <p>First I created the <code>/login</code> resource and a <code>GET</code> method, to which I added a mock integration.</p>
  
  <p><a href="https://i.stack.imgur.com/ZYGuO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZYGuO.png" alt="Integration Request"></a></p>
  
  <p>I set 302 at Method Response:</p>
  
  <p><a href="https://i.stack.imgur.com/ow3PW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ow3PW.png" alt="Method Response"></a></p>
  
  <p>Finally I added Integration Response:</p>
  
  <p><a href="https://i.stack.imgur.com/Vi7ah.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vi7ah.png" alt="Integration Response"></a></p>
  
  <p>However when I test the method, the Location header is missing. If I put a static string to the Location header in Integration Response it works, but whatever I try at the header mapping it is not working.</p>
  
  <p>Things I tried at Integration Request mapping:</p>
  
  <pre><code>{
    "statusCode": 200,
    "headers": {"target": "https://google.com"}
  }
  </code></pre>
  
  <pre><code>{
    "statusCode": 200,
    "target": "https://google.com"
  }
  </code></pre>
  
  <p>I seems that <code>integration.response.body.target</code> or <code>integration.response.header.target</code> is always empty.
  According to the documentation, <code>headers</code> property can be part of the integration response, but I cannot get any value from the Mapping Template I set at Integration Request.</p>
  
  <p>Any idea what I did incorrectly?</p>