AWS.TemporaryCredentials — AWS SDK for JavaScript (original) (raw)
We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
Overview
Note:
AWS.TemporaryCredentials is deprecated, but remains available for backwards compatibility. AWS.ChainableTemporaryCredentials is the preferred class for temporary credentials.
Note:
In order to create temporary credentials, you first need to have "master" credentials configured in AWS.Config.credentials. These master credentials are necessary to retrieve the temporary credentials, as well as refresh the credentials when they expire.
Represents temporary credentials retrieved from AWS.STS. Without any extra parameters, credentials will be fetched from theAWS.STS.getSessionToken() operation. If an IAM role is provided, theAWS.STS.assumeRole() operation will be used to fetch credentials for the role instead.
To setup temporary credentials, configure a set of master credentials using the standard credentials providers (environment, EC2 instance metadata, or from the filesystem), then set the global credentials to a new temporary credentials object:
// Note that environment credentials are loaded by default,
// the following line is shown for clarity:
AWS.config.credentials = new AWS.EnvironmentCredentials('AWS');
// Now set temporary credentials seeded from the master credentials
AWS.config.credentials = new AWS.TemporaryCredentials();
// subsequent requests will now use temporary credentials from AWS STS.
new AWS.S3().listBucket(function(err, data) { ... });
Constructor Summarycollapse
- new AWS.TemporaryCredentials(params, masterCredentials) ⇒ void constructor
Creates a new temporary credentials object.
Property Summarycollapse
- masterCredentials ⇒ AWS.Credentials readwrite
The master (non-temporary) credentials used to get and refresh temporary credentials from AWS STS.
Properties inherited from AWS.Credentials
expired, expireTime, accessKeyId, secretAccessKey, sessionToken, expiryWindow
Method Summarycollapse
Methods inherited from AWS.Credentials
needsRefresh, get, getPromise, refreshPromise
Constructor Details
new AWS.TemporaryCredentials(params, masterCredentials) ⇒ void
Note:
In order to create temporary credentials, you first need to have "master" credentials configured in AWS.Config.credentials. These master credentials are necessary to retrieve the temporary credentials, as well as refresh the credentials when they expire.
Creates a new temporary credentials object.
Property Details
masterCredentials ⇒ AWS.Credentials
Returns the master (non-temporary) credentials used to get and refresh temporary credentials from AWS STS.