{"action":"closed","issue":{"url":"https://api.github.com/repos/aws/amazon-cognito-identity-js/issues/61","repository_url":"https://api.github.com/repos/aws/amazon-cognito-identity-js","labels_url":"https://api.github.com/repos/aws/amazon-cognito-identity-js/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/aws/amazon-cognito-identity-js/issues/61/comments","events_url":"https://api.github.com/repos/aws/amazon-cognito-identity-js/issues/61/events","html_url":"https://github.com/aws/amazon-cognito-identity-js/issues/61","id":159747378,"number":61,"title":"Question: Configuring API Gateway SDK using CognitoUser credentials","user":{"login":"hofan41","id":5480450,"avatar_url":"https://avatars.githubusercontent.com/u/5480450?v=3","gravatar_id":"","url":"https://api.github.com/users/hofan41","html_url":"https://github.com/hofan41","followers_url":"https://api.github.com/users/hofan41/followers","following_url":"https://api.github.com/users/hofan41/following{/other_user}","gists_url":"https://api.github.com/users/hofan41/gists{/gist_id}","starred_url":"https://api.github.com/users/hofan41/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hofan41/subscriptions","organizations_url":"https://api.github.com/users/hofan41/orgs","repos_url":"https://api.github.com/users/hofan41/repos","events_url":"https://api.github.com/users/hofan41/events{/privacy}","received_events_url":"https://api.github.com/users/hofan41/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-11T00:52:46Z","updated_at":"2016-06-18T00:53:43Z","closed_at":"2016-06-18T00:53:43Z","body":"It appears the de-facto way to configure an API Gateway SDK is the following:\r\n\r\n```\r\n                var apigClient = apigClientFactory.newClient({\r\n                    accessKey : 'ACCESS_KEY',\r\n                    secretKey : 'SECRET_KEY',\r\n                    sessionToken : 'SESSION_TOKEN'\r\n                });\r\n```\r\n\r\nIt seems that the CognitoUser.authenticateUser returns a CognitoUserSession consisted of the following:\r\n\r\n```\r\nID Token\r\nRefresh Token\r\nAccess Token\r\n```\r\n\r\nThese tokens appear to be the wrong set of keys that the API Gateway SDK is expecting. Reading further on the documents, it seems I need to make an additional call to `STS.assumeRoleWithWebIdentity` in order to get them. \r\n\r\nDigging through the implementation of the Cognito Identity SDK, I see that the credentials I need are already available internally inside the implementation of CognitoIdentityCredentials.\r\n\r\naws-cognito-sdk.js : 414\r\n```\r\n  loadCredentials: function loadCredentials(data, credentials) {\r\n    if (!data || !credentials) return;\r\n    credentials.expired = false;\r\n    credentials.accessKeyId = data.Credentials.AccessKeyId;\r\n    credentials.secretAccessKey = data.Credentials.SecretKey;\r\n    credentials.sessionToken = data.Credentials.SessionToken;\r\n    credentials.expireTime = data.Credentials.Expiration;\r\n  },\r\n```\r\n\r\nIs there some mechanism by which I can readily use these credentials instead of making a redundant call to STS? \r\n\r\nPlease advise. "}}
{"actor":{"display_login":"hofan41"}}