AWS Free Certification Courses

Please go to our Blogger site at blog.backspace.academy This site will no longer be updated.

Get CognitoSync Session Token

 

Now that we have our CognitoID credentials we can use these to access CognitoSync. First we need to use our new temporary credentials to create a CognitoSync session token.

We are going to create a new function to get our CognitoSync session token. Open app.js in your editor and add a call to the new function getCognitoSynToken() in the callback of getCognitoID().

In order to get the token we must make a call to listRecords. If our dataset doesn't exist (as is the case now) it will be created automatically. We also get the sync count for the dataset which is needed later to add or change dataset records. There is a call to a function addRecord() in the callback of cognitosync.listRecords() below, please comment this out for now as we will be building this later.

Now you can build and run your app. You should be able to login to Facebook, create a dataset and list the records.

Now that we have our CognitoSync Session Token we can use this in the next page to access the CognitoSync database and add records to the dataset.

Next Add CognitoSync Records