Created
April 30, 2016 22:59
-
-
Save marcelpanse/6e604a914955d74126e850b54ec6b4d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load this script first: <script src="https://apis.google.com/js/api.js?onload=init"></script> | |
gapi.load('auth2', function() { | |
googleAuth = gapi.auth2.init({client_id: '<your-google-api-key>.apps.googleusercontent.com'}) | |
googleAuth.signIn({'scope': 'profile email'}) | |
}) | |
// this is a-sync, you should wait till you get the googleAuth object before continueing. | |
AWS.config.region = 'eu-west-1' | |
AWS.config.id_token = id_token | |
AWS.config.credentials = new AWS.CognitoIdentityCredentials({ | |
IdentityPoolId: 'eu-west-1:c3d1617c-fc6e-4983-a867-6faaade8ddc7', | |
Logins: { // optional tokens, used for authenticated login | |
'accounts.google.com': googleAuth.id_token | |
} | |
}) | |
AWS.config.credentials.get(err => { | |
if (err) { | |
console.log('Error: ' + err) | |
} else { | |
console.log('access key id', AWS.config.credentials.accessKeyId) | |
console.log('secret access key', AWS.config.credentials.secretAccessKey) | |
console.log('session token', AWS.config.credentials.sessionToken) | |
// you can now use these keys to call the api gateway using the generated JS SDK for your AWS Gateway API. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment