Getting 403 (Forbidden) when trying to synchronize() to amazon cognito
<p>I am able to login into Facebook, get an access token and use this to access my identity pool at amazon cognito. When trying to synchronize() my local dataset with amazon I get the error <code>Failed to load resource: the server responded with a status of 403 (Forbidden)</code>.</p>

<p>It follows amazons <a href="http://docs.aws.amazon.com/cognito/latest/developerguide/step2-getting-started.html?shortFooter=true#store-sync-data-1.javascript" rel="nofollow">documentation</a> but I must be missing some credential since it does not work. In chrome I get the message <code>
{"message":"Missing Authentication Token"}</code> which clearly indicates that.</p>

<p>But the <a href="https://github.com/aws/amazon-cognito-js" rel="nofollow">sync manager github repo</a> does not show how to add more credentials other than the pool ID.</p>

<pre><code>function facebookSignIn(accessToken) {
    AWS.config.update({
        region: 'eu-west-1',
        credentials: new AWS.CognitoIdentityCredentials({
            IdentityPoolId: learnjs.poolId,
            Logins: {
                'graph.facebook.com': accessToken
            }
        })
    });

    AWS.config.credentials.get(function() {
        var client = new AWS.CognitoSyncManager();
        client.openOrCreateDataset('Timebooking', function(err, dataset) {
            dataset.put('1', 'En', function(err, record) {
                console.log('put(): ' + record);
                dataset.synchronize({
                    sessionToken: sessionToken,
                    onSuccess: function(dataset, newRecords) {
                        console.log('synchronize() onSuccess, length: ' + newRecords.length);
                    }
                });
            });
        });
    });
}
</code></pre>

<p>I have added the AWS SDK in html:</p>

<pre><code>&lt;script src='/aws-sdk.min.js'&gt;&lt;/script&gt;
&lt;script src='/amazon-cognito.min.js'&gt;&lt;/script&gt;
</code></pre>