AWS Code Sample


<!-- Copyright 2010-2018, Inc. or its affiliates. All Rights Reserved. // Licensed under the Apache-2.0 License on an "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND. // ABOUT THIS BROWSER SAMPLE: This sample is part of the SDK for JavaScript Developer Guide topic at // --> <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Amazon Cognito Credenials Example</title> <meta charset="utf-8"> <script src=""></script> </head> <body> <div id="results">data</div> <script type="application/javascript"> // Set your needed values var IDENTITY_POOL_ID = 'Your Cognito identity pool ID'; var ACCOUNT_ID = 'Your AWS account ID'; var REGION = 'Your AWS region'; // Initialize the Amazon Cognito credentials provider AWS.config.region = REGION; // Region AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: IDENTITY_POOL_ID,}); var getIdParams = { IdentityPoolId: IDENTITY_POOL_ID, AccountId: ACCOUNT_ID }; var cognitoidentity = new AWS.CognitoIdentity({apiVersion: '2014-06-30'}); cognitoidentity.getId(getIdParams, function(err, data) { if (err) { results.innerHTML = "Error" + err; } else { results.innerHTML = "Cognito Identity ID is " + data.IdentityId; } }); </script> </body> </html>