You are viewing the documentation for an older major version of the AWS SDK for JavaScript.
The modular AWS SDK for JavaScript (v3), the latest major version of AWS SDK for JavaScript, is now stable and recommended for general use. For more information, see the Migration Guide and API Reference.

Class: AWS.SharedJSONFileCredentials

Inherits:
AWS.Credentials show all
Defined in:
lib/credentials/shared_json_file_credentials.js

Overview

Note:

This feature is not supported in the browser environment of the SDK.

Represents credentials loaded from shared credentials file (defaulting to ~/.bluemix/cos_credentials).

Using the shared credentials file

This provider is checked by default in the Node.js environment. To use the credentials file provider, simply add your bluemix credentials in JSON format to the ~/.bluemix/cos_credentials file in the following format:

{ "apikey": "foo", "cos_hmac_keys": { "access_key_id": "bar", "secret_access_key": "baz" }, ... "resource_instance_id": "bang" }

Constructor Summary collapse

Property Summary

Properties inherited from AWS.Credentials

expired, expireTime, accessKeyId, secretAccessKey, sessionToken, expiryWindow

Method Summary collapse

Methods inherited from AWS.Credentials

needsRefresh, get, getPromise, refreshPromise

Constructor Details

new AWS.SharedJSONFileCredentials(options) ⇒ void

Creates a new SharedJSONFileCredentials object.

Parameters:

  • options (map)

    a set of options

Options Hash (options):

  • profile (String) — default: AWS_PROFILE env var or 'default'

    the name of the profile to load.

  • filename (String) — default: '~/.aws/credentials'

    the filename to use when loading credentials.

  • disableAssumeRole (Boolean) — default: false

    True to disable support for profiles that assume an IAM role. If true, and an assume role profile is selected, an error is raised.

Method Details

refresh(callback) ⇒ void

Loads the credentials from the shared credentials file

Callback (callback):

  • function(err) { ... }

    Called after the shared JSON file on disk is read and parsed. When this callback is called with no error, it means that the credentials information has been loaded into the object (as the accessKeyId, secretAccessKey, and sessionToken properties).

    Parameters:

    • err (Error)

      if an error occurred, this value will be filled

See Also:

  • AWS.SharedJSONFileCredentials.get