title: AWS amplify - Can't synchronize via DataStore if I use an API Key; but Cognito User Pools work
body: <p>I've setup an amplify project for react.js, which should allow authorized and unauthorized access to my application.
  Therefore, I've configured two authentication methods: Cognito User Pools and API key. The first one is my default.
  My application runs fine, if I sign in via the Cognito User Pool. All data is beeing synchronized via the DataStore.
  But if I switch to the API Key as unauthenticated user, I only get unauthorized errors under the hood. E.g. for one of my custom types:</p>
  <pre><code>errorType: &quot;Unauthorized&quot;
  message: &quot;Not Authorized to access onCreateMyCustomType on type Subscription&quot;
  </code></pre>
  <p>The API key is sent correctly as &quot;x-api-key&quot;.</p>
  <p>If I manually query the Graph-API (e.g. via the amplify.js-API in my application or the third party tool GraphiQL), I can get the results. Just the synchronization isn't working as it does for authenticated users.</p>
  <p>In my schema, I control the access via @auth. E.g.:</p>
  <pre><code>@auth(rules: [
      # Owner access
      { allow: owner },
  
      # System access
      { allow: private, provider: iam },
  
      # Admin access
      { allow: groups, groups: [&quot;Admin&quot;] },
  
      # Default user access
      { allow: groups, groups: [&quot;User&quot;], operations: [read] },
  
      # Everyone
      { allow: public, operations: [read] }
    ])
  </code></pre>
  <p>I'm switching the authentication method via:</p>
  <pre><code>Amplify.configure({
    ...awsconfig,
    aws_appsync_authenticationType: isAuthenticated ? 'AMAZON_COGNITO_USER_POOLS' : 'API_KEY',
  });
  </code></pre>