title: Amplify, ionic. mobile HUB and api gateway authorization
body: <p>I configured amplify in a ionic project which has been tied to a mobilehub project.</p>
  
  <p>The apis have been created using the serverless framework:</p>
  
  <pre><code>functions:
    device:
        handler: handler.device
        events:
          - http:
              path: devices
              method: get
              authorizer: aws_iam
          - http:
              path: devices
              method: put
              authorizer: aws_iam
          - http:
              path: devices
              method: post
              authorizer: aws_iam
          - http:
              path: devices
              method: delete
              authorizer: aws_iam
  </code></pre>
  
  <p>The APIs work and to my knowledge are tied to my cognito user pools. In fact, when I call a get on that API, I get a "missing token" message.</p>
  
  <p>I am trying to implement the API call in an Ionic application. The application is the Ionic <code>aws</code> template, so it is able to login to cognito without problems.</p>
  
  <p>I downloaded the 'aws-exports.js' file from the mobilehub page, included in my sources and imported </p>
  
  <pre><code>import awsmobile from '../../aws-exports';
  import Amplify, { API } from 'aws-amplify';
  
  ionViewDidLoad(){
  
      Amplify.configure(awsmobile);
      console.log(Amplify);
  
      let apiName = 'dev-parameters';
      let path = '/devices';
  
      API.get(apiName, path).then(response =&gt; {
  
        debugger;
        console.log(response);
      });
  </code></pre>
  
  <p>}</p>
  
  <p>However I can see from the http calls that are made that an <code>OPTIONS</code> call is made that returns 403.</p>
  
  <p>Request:</p>
  
  <pre><code>:method GET
  :authority  cx1smjqtj5.execute-api.eu-west-1.amazonaws.com
  :scheme https
  :path   /dev/devices
  user-agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36     (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 OPR/50.0.2762.67
  upgrade-insecure-requests   1
  accept      text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=    0.8
  accept-encoding gzip, deflate, br
  accept-language en-GB,en-US;q=0.9,en;q=0.8
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>{
      "message": "Missing Authentication Token"
  }
  </code></pre>
  
  <p>I really don't understand what I am missing or doing wrong here.</p>