// API callback
related_results_labels_thumbs({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-4603622075690903012"},"updated":{"$t":"2023-10-23T04:18:30.735-07:00"},"category":[{"term":"AWS"},{"term":"AWS Certified Solutions Architect"},{"term":"Architect"},{"term":"Certification"},{"term":"AWS Certified Developer"},{"term":"AWS Certified SysOps Administrator"},{"term":"EC2"},{"term":"Course"},{"term":"Development"},{"term":"Cognito"},{"term":"Tutorial"},{"term":"SysOps Administration"},{"term":"CloudFront"},{"term":"News"},{"term":"S3"},{"term":"AutoScaling"},{"term":"Cordova"},{"term":"DynamoDB"},{"term":"ELB"},{"term":"IAM"},{"term":"Node.JS"},{"term":"PhoneGap"},{"term":"Security"},{"term":"Shared Responsibility"},{"term":"VPC"},{"term":"Amazon Aurora"},{"term":"Android"},{"term":"Denial of Service"},{"term":"EBS"},{"term":"IOS"},{"term":"NodeJS"},{"term":"RDS"},{"term":"AWS IoT"},{"term":"AWS Mobile Hub"},{"term":"Amazon Inspector"},{"term":"Amazon QuickSight"},{"term":"AngularJS"},{"term":"CloudTrail"},{"term":"Cloudformation"},{"term":"Dynamic"},{"term":"ECS"},{"term":"India"},{"term":"Internet of Things"},{"term":"Kinesis Firehose"},{"term":"MEAN"},{"term":"MariaDB"},{"term":"PIOPS"},{"term":"PhantomJS"},{"term":"ReactJS"},{"term":"Region"},{"term":"Route 53"},{"term":"Selenium"},{"term":"Trusted Adviser"},{"term":"WAF"},{"term":"Web Application Firewall"},{"term":"YAML"},{"term":"app"},{"term":"example"}],"title":{"type":"text","$t":"BackSpace Academy Blog"},"subtitle":{"type":"html","$t":"A blog about all things Amazon Web Services (AWS) and Cloud Certification."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"http:\/\/learn-aws.blogspot.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/-\/Cordova?alt=json-in-script\u0026max-results=6"},{"rel":"alternate","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/search\/label\/Cordova"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"BackSpace Academy"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/15061292652079774775"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"3"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-4603622075690903012.post-3331215387335751675"},"published":{"$t":"2015-04-03T02:33:00.001-07:00"},"updated":{"$t":"2016-07-12T21:01:44.718-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"AWS"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cognito"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cordova"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Development"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PhoneGap"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Tutorial"}],"title":{"type":"text","$t":"Using Cognito with PhoneGap\/Cordova - Part 3"},"content":{"type":"html","$t":"\u003Ch2\u003E\nAdd CognitoSync Records\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/blog.backspace.academy\/2015\/03\/using-cognito-with-phonegapcordova-part_31.html\"\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/blog.backspace.academy\/2015\/03\/using-cognito-with-phonegapcordova-part_31.html\"\u003Eback to Part 2\u0026nbsp;\u003C\/a\u003E\u003Cbr \/\u003E\nCode for tutorial is at\u0026nbsp;\u003Ca href=\"https:\/\/gist.github.com\/pcoady\/b09fdd59a3c0aed35ae8\" target=\"_blank\"\u003EGithub Gist\u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cbr \/\u003E\nNow that we have our CognitoSync session token we can use this to add, modify or delete CognitoSync dataset records.\u003Cbr \/\u003E\nTo demonstrate we are going to call addRecord to add a record. Open\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E\u0026nbsp;in your editor and add a call to the addRecord in the callback of getCognitoSynToken().\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction getCognitoSynToken(){\n  \/\/ Other AWS SDKs will automatically use the Cognito Credentials provider\n  \/\/ configured in the JavaScript SDK.\n  cognitosync = new AWS.CognitoSync();\n  cognitosync.listRecords({\n    DatasetName: COGNITO_DATASET_NAME, \/\/ required\n    IdentityId: COGNITO_IDENTITY_ID,  \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID  \/\/ required\n  }, function(err, data) {\n    if (err){\n      errorMessage += \"listRecords: \" + err, err.stack + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred       \n    }\n    else {\n      COGNITO_SYNC_TOKEN = data.SyncSessionToken;\n      COGNITO_SYNC_COUNT = data.DatasetSyncCount;\n      message += \"listRecords: \" + JSON.stringify(data) + \"_____\"; \n      message += \"DatasetSyncCount: \" + COGNITO_SYNC_COUNT + \"_____\";      \n      $('#appConsole').text(message);       \/\/ successful response\n      addRecord();         \n    }\n  });\n}\n\u003C\/pre\u003E\nNow lets add a record user_id that stores the users facebook id. We need to not only pass the CognitoSync session token but also the sync count that we got from the call to listRecords. \u003Cb\u003EThere is a call to a function createS3() in the callback of addRecord() below, please comment this out for now as we will be building this later.\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction addRecord(){\n  var params = {\n    DatasetName: COGNITO_DATASET_NAME, \/\/ required\n    IdentityId: COGNITO_IDENTITY_ID, \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID, \/\/ required\n    SyncSessionToken: COGNITO_SYNC_TOKEN, \/\/ required\n    RecordPatches: [\n      {\n        Key: 'USER_ID', \/\/ required\n        Op: 'replace', \/\/ required\n        SyncCount: COGNITO_SYNC_COUNT, \/\/ required\n        Value: FACEBOOK_USER.id\n      }\n    ]\n  };\n  console.log(\"UserID: \".cyan + FACEBOOK_USER.id);\n  cognitosync.updateRecords(params, function(err, data) {\n    if (err){\n      errorMessage += \"updateRecords: \" + err, err.stack + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred        \n    }\n    else{\n      message += \"Value: \" + JSON.stringify(data) + \"_____\";      \n      $('#appConsole').text(message);       \/\/ successful response      \n      createS3();\n    }     \n  });\n}\n\u003C\/pre\u003E\nNow you can build and run your app. You should be able to login to Facebook and add a user record to the dataset.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nWe can also use our CognitoID credentials to access other AWS resources. Next we will access an S3 bucket and add a folder and file to it.\u003Cbr \/\u003E\n\u003Ch2\u003E\nAccess an AWS S3 Bucket\u003C\/h2\u003E\nNot only can we use our CognitoID temporary credentials do access CongitoSync, we can use it access many other AWS resources.\u003Cbr \/\u003E\nFirst we need to modify our apps IAM role to allow access to S3.\u0026nbsp;\u003Cb\u003EIt is extremely important when doing this to ensure that the user only has access to a folder with their CognitoID\u003C\/b\u003E. Otherwise someone can maliciously dump a few terabytes into your S3 bucket or even worse start deleting objects.\u003Cbr \/\u003E\nGo into the AWS IAM Console.\u003Cbr \/\u003E\nClick on roles and select the IAM role you created.\u003Cbr \/\u003E\nClick on Manage Policy\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Cimg alt=\"AWS IAM Policy\" src=\"http:\/\/backspace.technology\/images\/tutorials\/cognito-phonegap7-1.png\" height=\"503\" width=\"840\" \/\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\nNow change the policy to allow access to a folder in the user's CognitoID.\u0026nbsp;\u003Cb\u003EIt is very important to ensure that the \"Version\": \"2012-10-17\" statement is included otherwise the policy variables will not be recognised.\u003C\/b\u003E\u0026nbsp;Then click on Apply Policy.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003E{\n\"Version\": \"2012-10-17\",\n    \"Statement\": \n    [\n     {\n         \"Action\": [\n             \"mobileanalytics:PutEvents\",\n             \"cognito-sync:*\"\n         ],\n         \"Effect\": \"Allow\",\n         \"Resource\": [\n             \"*\"\n         ]\n     },\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"s3:GetObject\",\n        \"s3:PutObject\",\n        \"s3:PutObjectAcl\",\n        \"s3:DeleteObject\"\n      ],\n      \"Resource\": [\n        \"arn:aws:s3:::backspace-cognito-test\/${cognito-identity.amazonaws.com:sub}\/*\",\n        \"arn:aws:s3:::backspace-cognito-test\/${cognito-identity.amazonaws.com:sub}\"\n      ]\n    }\n  ]\n}\n\u003C\/pre\u003E\nTo demonstrate we are going to call createS3 to create a folder in the user's name and add an object to it. Open\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E\u0026nbsp;in your editor and add a call to the createS3 in the callback of addRecord().\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction addRecord(){\n  var params = {\n    DatasetName: COGNITO_DATASET_NAME, \/\/ required\n    IdentityId: COGNITO_IDENTITY_ID, \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID, \/\/ required\n    SyncSessionToken: COGNITO_SYNC_TOKEN, \/\/ required\n    RecordPatches: [\n      {\n        Key: 'USER_ID', \/\/ required\n        Op: 'replace', \/\/ required\n        SyncCount: COGNITO_SYNC_COUNT, \/\/ required\n        Value: FACEBOOK_USER.id\n      }\n    ]\n  };\n  console.log(\"UserID: \".cyan + FACEBOOK_USER.id);\n  cognitosync.updateRecords(params, function(err, data) {\n    if (err){\n      errorMessage += \"updateRecords: \" + err, err.stack + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred        \n    }\n    else{\n      message += \"Value: \" + JSON.stringify(data) + \"_____\";      \n      $('#appConsole').text(message);       \/\/ successful response      \n      createS3();\n    }     \n  });\n}\n\u003C\/pre\u003E\nNext you need to go into the AWS S3 Console and create a bucket.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Cimg alt=\"AWS S3 Console\" src=\"http:\/\/backspace.technology\/images\/tutorials\/cognito-phonegap7-2.png\" height=\"303\" width=\"720\" \/\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\nNow lets add a folder to the bucket in the name of the user's CognitoID. Then we will add a text file to it with the contents \"Hello\". You need to change the bucket name to the name of your bucket.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction createS3(){\n  var bucket = new AWS.S3({\n    params: {\n      Bucket: 'backspace-cognito-test'\n    }\n  });\n  \/\/Object key will be facebook-USERID#\/FILE_NAME\n  var objKey = COGNITO_IDENTITY_ID+'\/test.txt';\n  var params = {\n      Key: objKey,\n      ContentType: 'text\/plain',\n      Body: \"Hello!\",\n      ACL: 'public-read'\n  };\n  bucket.putObject(params, function (err, data) {\n    if (err) {\n      errorMessage += 'COGNITO_IDENTITY_ID: ' + COGNITO_IDENTITY_ID + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred        \n      errorMessage += 'putObject: ' + err + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred        \n    } else {\n      message += \"Successfully uploaded data to your S3 bucket\" + \"_____\";      \n      $('#appConsole').text(message);       \/\/ successful response        \n    }\n  });\n}\n\u003C\/pre\u003E\nNow you can build and run your app. You should be able to login to Facebook and access S3.\u003Cbr \/\u003E\nIts all up to you now to identify how you are going to use this power! Maybe some big data crunching with Elastic Map Reduce, backup to Glacier or some heavy scientific processing with EC2.\u003Cbr \/\u003E\n\u003Cb\u003ELike coding? AWS Certified Developers are in HOT demand! Check out \u003Ca href=\"http:\/\/backspace.academy\/\" target=\"_blank\"\u003EBackSpace Academy\u003C\/a\u003E for more details.\u003C\/b\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"http:\/\/learn-aws.blogspot.com\/feeds\/3331215387335751675\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/04\/using-cognito-with-phonegapcordova-part.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/3331215387335751675"},{"rel":"self","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/3331215387335751675"},{"rel":"alternate","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/04\/using-cognito-with-phonegapcordova-part.html","title":"Using Cognito with PhoneGap\/Cordova - Part 3"}],"author":[{"name":{"$t":"BackSpace Academy"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/15061292652079774775"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-4603622075690903012.post-3552965143634019338"},"published":{"$t":"2015-03-31T02:38:00.000-07:00"},"updated":{"$t":"2016-07-12T21:01:17.170-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"AWS"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cognito"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cordova"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Development"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PhoneGap"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Tutorial"}],"title":{"type":"text","$t":"Using Cognito with PhoneGap\/Cordova - Part 2"},"content":{"type":"html","$t":"\u003Ch2\u003E\nFacebook Sign in with OpenFB\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/blog.backspace.academy\/2015\/03\/using-cognito-with-phonegapcordova-part.html\"\u003Eback to Part 1 \u003C\/a\u003E\u003Cbr \/\u003E\nCode for tutorial is at\u0026nbsp;\u003Ca href=\"https:\/\/gist.github.com\/pcoady\/b09fdd59a3c0aed35ae8\" target=\"_blank\"\u003EGithub Gist\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/coenraets.org\/blog\/author\/admin\/\" rel=\"author\" title=\"Posts by Christophe Coenraets\"\u003EChristophe Coenraets\u003C\/a\u003E\u0026nbsp;has created a excellent lightweight library for Facebook integration with Cordova\/PhoneGap. Download it from\u003Ca href=\"https:\/\/github.com\/ccoenraets\/OpenFB\"\u003Ehttps:\/\/github.com\/ccoenraets\/OpenFB\u003C\/a\u003E\u0026nbsp;.\u003Cbr \/\u003E\nAfter you have downloaded OpenFB, create a template PhoneGap Build application and put\u0026nbsp;\u003Ci\u003Elogoutcallback.html\u003C\/i\u003E\u0026nbsp;and\u0026nbsp;\u003Ci\u003Eoauthcallback.html\u0026nbsp;\u003C\/i\u003Ein the root folder with\u003Ci\u003Eindex.html\u003C\/i\u003E.\u003Cbr \/\u003E\nCreate a folder called js and put\u0026nbsp;\u003Ci\u003Eopenfb.js\u003C\/i\u003E\u0026nbsp;in it.\u003Cbr \/\u003E\nIn order to improve the way OpenFB works with PhoneGap\/Cordova we need to make a couple of changes. OpenFB uses the deviceready event to identify whether the app is using PhoneGap\/Cordova. For reliability I prefer to pass this directly to OpenFB on initialisation. Also the address bar is not used when the inappbrowser is opened. This means if anything goes wrong the user is presented with a blank white screen.\u003Cbr \/\u003E\nOpen in your editor\u003Ci\u003E\u0026nbsp;openfb.js\u003C\/i\u003E\u0026nbsp;and add a\u0026nbsp;\u003Ci\u003Ecordova\u0026nbsp;\u003C\/i\u003Eparameter to the init function:\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003E    \/**\n     * Initialize the OpenFB module. You must use this function and initialize the module with an appId before you can\n     * use any other function.\n     * @param params - init paramters\n     *  appId: The id of the Facebook app,\n     *  tokenStore: The store used to save the Facebook token. Optional. If not provided, we use sessionStorage.\n     *\/\n    function init(params) {\n        if (params.appId) {\n            fbAppId = params.appId;\n            if (params.cordova!=null){\n                runningInCordova = params.cordova;\n            }\n        } else {\n            throw 'appId parameter not set in init()';\n        }\n\n        if (params.tokenStore) {\n            tokenStore = params.tokenStore;\n        }\n    }\n\u003C\/pre\u003E\n\u003Cbr \/\u003E\nAlso change all window.open calls to 'location=yes';\u003Cbr \/\u003E\n\u003Cspan style=\"font-family: inherit;\"\u003E\u003Cspan style=\"font-family: inherit; font-size: inherit;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\nNow open your config.xml file and add the inappbrowser plugin.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: xml\"\u003E\n\u003C!-- config.xml reference: https:\/\/build.phonegap.com\/docs\/config-xml --\u003E\n\u003Cwidget id=\"technology.backspace.aws.cognito.example\" version=\"1.0.0\" xmlns:gap=\"http:\/\/phonegap.com\/ns\/1.0\" xmlns=\"http:\/\/www.w3.org\/ns\/widgets\"\u003E\n\n    \u003Cname\u003EAWS Cognito Example App\u003C\/name\u003E\n\n    \u003Cdescription\u003E\n        Example app using AWS Cognito \n    \u003C\/description\u003E\n\n    \u003Cauthor email=\"web@all-spammers-must-die.com\" href=\"http:\/\/backspace.technology\"\u003E\n        Paul Coady\n    \u003C\/author\u003E\n\n    \u003Cpreference name=\"phonegap-version\" value=\"3.5.0\"\u003E\n    \u003Cgap:plugin name=\"org.apache.cordova.inappbrowser\" version=\"0.2.4\"\u003E\n\u003C\/gap:plugin\u003E\u003C\/preference\u003E\u003C\/widget\u003E\n\u003C\/pre\u003E\nNow lets create a simple\u0026nbsp;\u003Ci\u003Eindex.html\u003C\/i\u003E\u0026nbsp;page with our login buttons and status output. This will load Jquery and the AWS Javascript SDK.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: html\"\u003E\u003Chtml\u003E\n  \u003Chead\u003E\n    \u003Ctitle\u003EAWS Cognito App\u003C\/title\u003E\n    \u003Cscript charset=\"utf-8\" src=\"phonegap.js\" type=\"text\/javascript\"\u003E\u003C\/script\u003E\n    \u003Clink href=\"http:\/\/code.jquery.com\/mobile\/1.4.3\/jquery.mobile-1.4.3.min.css\" rel=\"stylesheet\"\u003E\u003C\/link\u003E \n  \u003C\/head\u003E\n  \u003Cbody\u003E\n        \u003Cbutton id=\"btnLogin\"\u003ELogin with Facebook\u003C\/button\u003E\n        \u003Cbutton id=\"btnLogout\"\u003ELogout\u003C\/button\u003E\n        \u003Chr \/\u003E\n        \u003Cdiv style=\"height: 200px; overflow-y: scroll;\"\u003E\n\u003Cspan id=\"appConsole\" style=\"color: green; word-wrap: break-word;\"\u003E\u003C\/span\u003E\u003C\/div\u003E\n\u003Chr \/\u003E\n        \u003Cdiv style=\"height: 200px; overflow-y: scroll;\"\u003E\n\u003Cspan id=\"errorConsole\" style=\"color: red; word-wrap: break-word;\"\u003E\u003C\/span\u003E\u003C\/div\u003E\n\u003Cscript src=\"http:\/\/code.jquery.com\/jquery-2.1.1.min.js\" type=\"text\/javascript\"\u003E\u003C\/script\u003E        \n    \u003Cscript src=\"http:\/\/code.jquery.com\/mobile\/1.4.3\/jquery.mobile-1.4.3.min.js\"\u003E\u003C\/script\u003E        \n    \u003Cscript src=\"https:\/\/sdk.amazonaws.com\/js\/aws-sdk-2.0.15.min.js\"\u003E\u003C\/script\u003E        \n    \u003Cscript src=\"js\/openfb.js\" type=\"text\/javascript\"\u003E\u003C\/script\u003E\n    \u003Cscript src=\"js\/app.js\" type=\"text\/javascript\"\u003E\u003C\/script\u003E\n  \u003C\/body\u003E\n\u003C\/html\u003E\n\u003C\/pre\u003E\nNext create a file\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E\u0026nbsp;in the js folder. Create a self-invoking anonymous function to contain our code.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003E(function($){\n\n\n \n})(jQuery); \n\u003C\/pre\u003E\nAdd variables in\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E:\u003Cbr \/\u003E\nAWS_ACCOUNT_ID - This is your AWS account number.\u003Cbr \/\u003E\nCOGNITO_IDENTITY_POOL_ID - You can get this from your Cognito dashboard by selecting\u0026nbsp;\u003Ci\u003EEdit Identity Pool\u003C\/i\u003E\u003Cbr \/\u003E\nIAM_ROLE_ARN - This is the IAM role created when you created your Cognito pool. You can get this from the the main Services menu - IAM - Roles - then select the role for your identity pool.\u003Cbr \/\u003E\nFACEBOOK_APP_ID - From the facebook app page.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Evar AWS_ACCOUNT_ID = 'XXXXXXXX';\nvar AWS_REGION = 'us-east-1';\nvar COGNITO_IDENTITY_POOL_ID = 'us-east-1:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX';\nvar COGNITO_IDENTITY_ID, COGNITO_SYNC_TOKEN, AWS_TEMP_CREDENTIALS; \nvar cognitosync;\nvar IAM_ROLE_ARN = 'arn:aws:iam::XXXXXXXXX:role\/Cognito_CognitoBrowserExampleAuth_DefaultRole';\nvar COGNITO_SYNC_COUNT;\nvar COGNITO_DATASET_NAME = 'TEST_DATASET';\nvar FACEBOOK_APP_ID = 'XXXXXXXXXXXXXX';\nvar FACEBOOK_TOKEN;\nvar FACEBOOK_USER = {\n  id: '',\n  first_name: '',\n  gender: '',\n  last_name: '',\n  link: '',\n  locale: '',\n  name: '',\n  timezone: 0,\n  updated_time: '',\n  verified: false \n};\nvar userLoggedIn = false;\n\nvar message = 'AWS Cognito Example App Loaded_____';\nvar errorMessage = '';\n\u003C\/pre\u003E\n\u003Cbr \/\u003E\nNow add some code for our button events and clearing our status areas.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction clearConsole(){\n    message = \"\";\n    $('#appConsole').html(message);\n    errorMessage = \"\";\n    $('#errorConsole').html(errorMessage);    \n}\n\n\/\/ Login button\n$('#btnLogin').on('click', function (event) {\n    login();\n});\n\n\/\/ Login button\n$('#btnLogout').on('click', function (event) {\n    logout();\n});\n\u003C\/pre\u003E\nNow lets add our call to OpenFB.init and functions for handling login, logout, revoke permissions (not used here) and getting user info. I won't go into much detail here as this is explained on the OpenFB Github.\u0026nbsp;\u003Cb\u003EThere is a call to a function getCognitoID() in the callback of getInfo() below, please comment this out for now as we will be building this later.\u003C\/b\u003E\n\n\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003EopenFB.init({\n    appId:FACEBOOK_APP_ID, \n    cordova:true\n});\n\nfunction login() {\n    clearConsole();        \n    openFB.login(\n        function(response) {\n            if(response.status === 'connected') {\n                FACEBOOK_TOKEN = response.authResponse.token;\n                message += \"Connected to Facebook_____\";\n                $('#appConsole').text(message);\n                getInfo();\n            } else {\n                errorMessage += 'Facebook login failed: ' + response.error + \"_____\";\n                $('#errorConsole').text(errorMessage);\n            }\n        }, {scope: 'email,read_stream,publish_stream'});\n}\n\nfunction getInfo() {\n    openFB.api({\n        path: '\/me',\n        success: function(data) {            \n            message += \"Logged in with Facebook as \" + data.name+\"_____\";\n            $('#appConsole').text(message);\n            getCognitoID();\n        },\n        error: errorHandler});\n}\n\nfunction logout() {\n    openFB.logout(\n        function() {\n            message += \"Logged out of Facebook_____\";\n            $('#appConsole').text(message);\n        },\n        errorHandler);\n}\n\nfunction revoke() {\n    openFB.revokePermissions(\n        function() {\n            message += \"Permissions revoked_____\";\n            $('#appConsole').text(message);                \n        },\n        errorHandler);\n}\n\nfunction errorHandler(error) {\n    errorMessage += error.message;\n    $('#errorConsole').text(errorMessage);\n}\n\u003C\/pre\u003E\n\u003Cbr \/\u003E\nNow you can build and run your app. You should be able to login to Facebook.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nNow that we have our Facebook session token we will use this in the next page to get our Cognito ID credentials.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ch2\u003E\nGet CognitoID Credentials\u003C\/h2\u003E\nNow it's time to pass our Facebook token over to Cognito. Prior to version v2.0.14 of the AWS Javascript SDK this was a difficult process involving calls to IAM and STS. A new object CognitoIdentityCredentials has greatly simplified the CognitoID credentials process by removing the need to create STS tokens and temporary IAM credentials yourself.\u003Cbr \/\u003E\nWe are going to create a new function to get our CognitoID credentials. Open\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E\u0026nbsp;in your editor and add a call to the new function getCognitoID() in the success callback of our getInfo page.\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction getInfo() {\n    openFB.api({\n        path: '\/me',\n        success: function(data) {            \n            message += \"Logged in with Facebook as \" + data.name+\"_____\";\n            $('#appConsole').text(message);\n            getCognitoID();\n        },\n        error: errorHandler});\n}\n\u003C\/pre\u003E\nNow lets create the function.\u0026nbsp;\u003Cb\u003EThere is a call to a function getCognitoSynToken() in the callback of AWS.config.credentials.get() below, please comment this out for now as we will be building this later\u003C\/b\u003E.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction getCognitoID(){\n  \/\/ The parameters required to intialize the Cognito Credentials object.\n  var params = {\n    AccountId: AWS_ACCOUNT_ID, \/\/ required\n    RoleArn: IAM_ROLE_ARN,  \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID, \/\/ required\n    Logins: {\n      'graph.facebook.com': FACEBOOK_TOKEN\n    }  \n  };   \n  \/\/ set the Amazon Cognito region\n  AWS.config.region = AWS_REGION;\n  \/\/ initialize the Credentials object with our parameters\n  AWS.config.credentials = new AWS.CognitoIdentityCredentials(params);\n\n  \/\/ We can set the get method of the Credentials object to retrieve\n  \/\/ the unique identifier for the end user (identityId) once the provider\n  \/\/ has refreshed itself\n  AWS.config.credentials.get(function(err) {\n    if (err){ \/\/ an error occurred\n        errorMessage += \"credentials.get: \" + err, err.stack + \"_____\";\n        $('#errorConsole').text(errorMessage);\n        errorMessage += \"AWS.config.credentials: \" + JSON.stringify(AWS.config.credentials) + \"_____\";\n        $('#errorConsole').text(errorMessage);\n    }\n    else{\n      AWS_TEMP_CREDENTIALS = AWS.config.credentials;\n      COGNITO_IDENTITY_ID = AWS.config.credentials.identityId;\n      message += \"Cognito Identity Id: \" + COGNITO_IDENTITY_ID + \"_____\";\n      $('#appConsole').text(message);  \n      getCognitoSynToken();     \n    }\n  });\n}\n\u003C\/pre\u003E\n\u003Cbr \/\u003E\nNow you can build and run your app. You should be able to login to Facebook and get your user Cognito ID.\u003Cbr \/\u003E\nNow that we have our Cognito ID credentials we can use this in the next page to get our CognitoSync Session Token.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ch2\u003E\nGet CognitoSync Session Token\u003C\/h2\u003E\nNow 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.\u003Cbr \/\u003E\nWe are going to create a new function to get our CognitoSync session token. Open\u0026nbsp;\u003Ci\u003Eapp.js\u003C\/i\u003E\u0026nbsp;in your editor and add a call to the new function getCognitoSynToken() in the callback of getCognitoID().\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction getCognitoID(){\n  \/\/ The parameters required to intialize the Cognito Credentials object.\n  var params = {\n    AccountId: AWS_ACCOUNT_ID, \/\/ required\n    RoleArn: IAM_ROLE_ARN,  \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID, \/\/ required\n    Logins: {\n      'graph.facebook.com': FACEBOOK_TOKEN\n    }  \n  };   \n  \/\/ set the Amazon Cognito region\n  AWS.config.region = AWS_REGION;\n  \/\/ initialize the Credentials object with our parameters\n  AWS.config.credentials = new AWS.CognitoIdentityCredentials(params);\n\n  \/\/ We can set the get method of the Credentials object to retrieve\n  \/\/ the unique identifier for the end user (identityId) once the provider\n  \/\/ has refreshed itself\n  AWS.config.credentials.get(function(err) {\n    if (err){ \/\/ an error occurred\n        errorMessage += \"credentials.get: \" + err, err.stack + \"_____\";\n        $('#errorConsole').text(errorMessage);\n        errorMessage += \"AWS.config.credentials: \" + JSON.stringify(AWS.config.credentials) + \"_____\";\n        $('#errorConsole').text(errorMessage);\n    }\n    else{\n      AWS_TEMP_CREDENTIALS = AWS.config.credentials;\n      COGNITO_IDENTITY_ID = AWS.config.credentials.identityId;\n      message += \"Cognito Identity Id: \" + COGNITO_IDENTITY_ID + \"_____\";\n      $('#appConsole').text(message);  \n      getCognitoSynToken();     \n    }\n  });\n}\n\u003C\/pre\u003E\nIn 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.\u0026nbsp;\u003Cb\u003EThere 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.\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cpre class=\"brush: js\"\u003Efunction getCognitoSynToken(){\n  \/\/ Other AWS SDKs will automatically use the Cognito Credentials provider\n  \/\/ configured in the JavaScript SDK.\n  cognitosync = new AWS.CognitoSync();\n  cognitosync.listRecords({\n    DatasetName: COGNITO_DATASET_NAME, \/\/ required\n    IdentityId: COGNITO_IDENTITY_ID,  \/\/ required\n    IdentityPoolId: COGNITO_IDENTITY_POOL_ID  \/\/ required\n  }, function(err, data) {\n    if (err){\n      errorMessage += \"listRecords: \" + err, err.stack + \"_____\";\n      $('#errorConsole').text(errorMessage); \/\/ an error occurred       \n    }\n    else {\n      COGNITO_SYNC_TOKEN = data.SyncSessionToken;\n      COGNITO_SYNC_COUNT = data.DatasetSyncCount;\n      message += \"listRecords: \" + JSON.stringify(data) + \"_____\"; \n      message += \"DatasetSyncCount: \" + COGNITO_SYNC_COUNT + \"_____\";      \n      $('#appConsole').text(message);       \/\/ successful response\n      addRecord();         \n    }\n  });\n}\n\u003C\/pre\u003E\n\u003Cbr \/\u003E\nNow you can build and run your app. You should be able to login to Facebook, create a dataset and list the records.\u003Cbr \/\u003E\nNow that we have our CognitoSync Session Token we can use this in the next \u003Ca href=\"http:\/\/blog.backspace.academy\/2015\/04\/using-cognito-with-phonegapcordova-part.html\" target=\"_blank\"\u003Epart 3\u003C\/a\u003E to access the CognitoSync database and add records to the dataset."},"link":[{"rel":"replies","type":"application/atom+xml","href":"http:\/\/learn-aws.blogspot.com\/feeds\/3552965143634019338\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/03\/using-cognito-with-phonegapcordova-part_31.html#comment-form","title":"3 Comments"},{"rel":"edit","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/3552965143634019338"},{"rel":"self","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/3552965143634019338"},{"rel":"alternate","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/03\/using-cognito-with-phonegapcordova-part_31.html","title":"Using Cognito with PhoneGap\/Cordova - Part 2"}],"author":[{"name":{"$t":"BackSpace Academy"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/15061292652079774775"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"3"}},{"id":{"$t":"tag:blogger.com,1999:blog-4603622075690903012.post-226587141528744032"},"published":{"$t":"2015-03-28T06:09:00.003-07:00"},"updated":{"$t":"2016-07-12T21:00:52.669-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"AWS"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cognito"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Cordova"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Development"},{"scheme":"http://www.blogger.com/atom/ns#","term":"PhoneGap"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Tutorial"}],"title":{"type":"text","$t":"Using Cognito with PhoneGap\/Cordova - Part 1"},"content":{"type":"html","$t":"\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/2.bp.blogspot.com\/-qShZkoZH50U\/VzybwFhte8I\/AAAAAAAAARs\/tggo0clTq6w99MtVLs-RsKYBCBzj0iLpwCLcB\/s1600\/Cognito_Cordova.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" height=\"180\" src=\"https:\/\/2.bp.blogspot.com\/-qShZkoZH50U\/VzybwFhte8I\/AAAAAAAAARs\/tggo0clTq6w99MtVLs-RsKYBCBzj0iLpwCLcB\/s320\/Cognito_Cordova.png\" width=\"320\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nThe potential for really powerful mobile applications is huge when Cognito is used to combine the power of AWS with your PhoneGap\/Cordova application. It is also a great low cost alternative to Parse.com when used  for  storing user information.\u003Cbr \/\u003E\nThis tutorial will focus on using  Cognito with the AWS Javascript SDK for Browser along with the excellent OpenFB library developed by \u003Ca href=\"http:\/\/coenraets.org\/blog\/author\/admin\/\" rel=\"author\" title=\"Posts by Christophe Coenraets\"\u003EChristophe Coenraets\u003C\/a\u003E\u0026nbsp;to simplify token creation. The sample app will be created for the Adobe PhoneGap Build process. This could be used with apps that access files on an S3 bucket and also require user information to be stored. I have chosen Facebook as the identity provider but a similar process applies for Amazon and Google. I would recommend only using one identity provider for your app so that your users don't produce multiple Cognito key stores.\u003Cbr \/\u003E\nWith the release of v2.0.14 of the AWS Javascript SDK, a new object CognitoIdentityCredentials has greatly simplified the CognitoID credentials process by removing the need to create STS tokens and  temporary IAM credentials. The simplified process to create a Cognito session is as follows:\u003Cbr \/\u003E\n\u003Cspan id=\"goog_1790937174\"\u003E\u003C\/span\u003E\u003Cspan id=\"goog_1790937175\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"http:\/\/4.bp.blogspot.com\/-1-ERBvYOQos\/VRagRdnwgsI\/AAAAAAAAAMY\/22Ad3jGbLA0\/s1600\/cognito-process-phonegap.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-1-ERBvYOQos\/VRagRdnwgsI\/AAAAAAAAAMY\/22Ad3jGbLA0\/s1600\/cognito-process-phonegap.png\" style=\"height: auto; max-width: 952px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\nCode for tutorial is at\u0026nbsp;\u003Ca href=\"https:\/\/gist.github.com\/pcoady\/b09fdd59a3c0aed35ae8\" target=\"_blank\"\u003EGithub Gist\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Ch1\u003E\nRegister a Facebook App\u003C\/h1\u003E\n\u003Cbr \/\u003E\n\u003Cb\u003EThis process is different to that used with NodeJS because the app will be running from the device local domain.\u003C\/b\u003E\u003Cbr \/\u003E\nGo to developers.facebook.com and select Apps - Create a New App\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"http:\/\/3.bp.blogspot.com\/-qwG6t0UUhp0\/VRaiXzL41vI\/AAAAAAAAAMk\/49_XNTadXH8\/s1600\/cognito-phonegap1-1.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-qwG6t0UUhp0\/VRaiXzL41vI\/AAAAAAAAAMk\/49_XNTadXH8\/s1600\/cognito-phonegap1-1.png\" style=\"height: auto; max-width: 719px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\nRecord your App ID and App Secret somewhere safe, we will need it later.\u003Cbr \/\u003E\nClick on Settings then click on Advanced (do not fill in app domain details or add platform).\u003Cbr \/\u003E\nSelect Native or Desktop app.\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: right; float: right; margin-bottom: 1em; margin-left: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: right; float: right; margin-bottom: 1em; margin-left: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: right; float: right; margin-bottom: 1em; margin-left: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"http:\/\/1.bp.blogspot.com\/-Sa7MT38Kv-U\/VRajAMOHuUI\/AAAAAAAAAMs\/91lU84W9u-k\/s1600\/cognito-phonegap1-2.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-Sa7MT38Kv-U\/VRajAMOHuUI\/AAAAAAAAAMs\/91lU84W9u-k\/s1600\/cognito-phonegap1-2.png\" style=\"height: auto; max-width: 732px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003E\u003Cbr \/\u003E\nAdd https:\/\/www.facebook.com\/connect\/login_success.html as the Valid OAuth redirect URI.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"http:\/\/3.bp.blogspot.com\/-M1JjJKwJol8\/VRajp8qX5YI\/AAAAAAAAAM4\/IRbLdMc_v_0\/s1600\/cognito-phonegap1-3.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-M1JjJKwJol8\/VRajp8qX5YI\/AAAAAAAAAM4\/IRbLdMc_v_0\/s1600\/cognito-phonegap1-3.png\" style=\"height: auto; max-width: 720px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\nEnter your  \u003Ci\u003Econtact email\u003C\/i\u003E and Save Changes\u003Cbr \/\u003E\nNext select \u003Ci\u003EStatus and Review\u003C\/i\u003E\u003Cbr \/\u003E\nToggle Yes for \u003Ci\u003EDo you want to make this app and all its live features available to the general public?\u003C\/i\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nNow that we have registered our new app with Facebook, we will tell Cognito all about it next.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ch1\u003E\nCreate a Cognito Pool\u003C\/h1\u003E\n\u003Cbr \/\u003E\nNow that we have a Facebook App registered we need to create a Cognito pool that will be linked to the Facebook app.\u003Cbr \/\u003E\n\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003E\u003Ca href=\"https:\/\/www.blogger.com\/blogger.g?blogID=4603622075690903012\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003C\/a\u003EGo to the Cognito start page and click Get Started Now\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"http:\/\/1.bp.blogspot.com\/-z9tuMScJM90\/VRanktj9kmI\/AAAAAAAAANM\/sYVn4g9Yv2M\/s1600\/cognito1-4.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-z9tuMScJM90\/VRanktj9kmI\/AAAAAAAAANM\/sYVn4g9Yv2M\/s1600\/cognito1-4.png\" style=\"height: auto; max-width: 971px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nStep 1:\u003Cbr \/\u003E\nGive your app a name in \u003Ci\u003EIdentity Pool Name\u003C\/i\u003E.\u003Cbr \/\u003E\nPaste your \u003Ci\u003EFacebook App ID\u003C\/i\u003E.\u003Cbr \/\u003E\nLeave \u003Ci\u003EEnable Access to Unauthenticated Identities\u003C\/i\u003E unchecked.\u003Cbr \/\u003E\nClick Create Pool\u003Cbr \/\u003E\nStep 2:\u003Cbr \/\u003E\nAn IAM role has been automatically created for you. Click Update Roles\u003Cbr \/\u003E\nStep 3:\u003Cbr \/\u003E\nExample code for native mobile apps has been created for you which is useless for us with javascript so just click Done.\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"http:\/\/2.bp.blogspot.com\/-ke1zbtKiUxU\/VRancoDKbwI\/AAAAAAAAANE\/a0nzMpWbNps\/s1600\/cognito-phonegap2-1.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-ke1zbtKiUxU\/VRancoDKbwI\/AAAAAAAAANE\/a0nzMpWbNps\/s1600\/cognito-phonegap2-1.png\" style=\"height: auto; max-width: 935px; width: 100%;\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nFinished! You have created a Cognito pool and are viewing its dashboard. Next, in \u003Ca href=\"http:\/\/blog.backspace.academy\/2015\/03\/using-cognito-with-phonegapcordova-part_31.html\" target=\"_blank\"\u003Epart 2\u003C\/a\u003E we will use OpenFB to sign in and get our Facebook session token."},"link":[{"rel":"replies","type":"application/atom+xml","href":"http:\/\/learn-aws.blogspot.com\/feeds\/226587141528744032\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/03\/using-cognito-with-phonegapcordova-part.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/226587141528744032"},{"rel":"self","type":"application/atom+xml","href":"http:\/\/www.blogger.com\/feeds\/4603622075690903012\/posts\/default\/226587141528744032"},{"rel":"alternate","type":"text/html","href":"http:\/\/learn-aws.blogspot.com\/2015\/03\/using-cognito-with-phonegapcordova-part.html","title":"Using Cognito with PhoneGap\/Cordova - Part 1"}],"author":[{"name":{"$t":"BackSpace Academy"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/15061292652079774775"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/2.bp.blogspot.com\/-qShZkoZH50U\/VzybwFhte8I\/AAAAAAAAARs\/tggo0clTq6w99MtVLs-RsKYBCBzj0iLpwCLcB\/s72-c\/Cognito_Cordova.png","height":"72","width":"72"},"thr$total":{"$t":"0"}}]}});