Setting Credentials in a Web Browser - AWS SDK for JavaScript

The AWS SDK for JavaScript version 3 (v3) is a rewrite of v2 with some great new features, including modular architecture. For more information, see the AWS SDK for JavaScript v3 Developer Guide.

Setting Credentials in a Web Browser

There are several ways to supply your credentials to the SDK from browser scripts. Some of these are more secure and others afford greater convenience while developing a script. Here are the ways you can supply your credentials in order of recommendation:

  1. Using Amazon Cognito Identity to authenticate users and supply credentials

  2. Using web federated identity

  3. Hard coded in the script


We do not recommend hard coding your AWS credentials in your scripts. Hard coding credentials poses a risk of exposing your access key ID and secret access key.