AuthUsingAcctOrUserCredentials
Making Requests Using AWS Account or IAM User Credentials
You can use your AWS account or IAM user security credentials to send authenticated requests to Amazon S3. This section provides examples of how you can send authenticated requests using the AWS SDK for Java, AWS SDK for .NET, and AWS SDK for PHP. For a list of available AWS SDKs, go to Sample Code and Libraries.
Topics
- Making Requests Using AWS Account or IAM User Credentials - AWS SDK for Java
- Making Requests Using AWS Account or IAM User Credentials - AWS SDK for .NET
- Making Requests Using AWS Account or IAM User Credentials - AWS SDK for PHP
- Making Requests Using AWS Account or IAM User Credentials - AWS SDK for Ruby
Each of these AWS SDKs uses an SDK-specific credentials provider chain to find and use credentials and perform actions on behalf of the credentials owner. What all these credentials provider chains have in common is that they all look for your local AWS credentials file.
The easiest way to configure credentials for your AWS SDKs is to use an AWS credentials file. If you use the AWS Command Line Interface (AWS CLI), you may already have a local AWS credentials file configured. Otherwise, use the following procedure to set up a credentials file:
To create a local AWS credentials file
Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
Create a new user with permissions limited to the services and actions that you want your code to have access to. For more information about creating a new IAM user, see Creating IAM Users (Console), and follow the instructions through step 8.
Choose Download .csv to save a local copy of your AWS credentials.
On your computer, navigate to your home directory, and create an
.aws
directory. On Unix-based systems, such as Linux or OS X, this is in the following location:~/.awsOn Windows, this is in the following location:
%HOMEPATH%\.awsIn the
.aws
directory, create a new file namedcredentials
.Open the credentials .csv file that you downloaded from the IAM console, and copy its contents into the
credentials
file using the following format:[default]aws_access_key_id = your_access_key_idaws_secret_access_key = your_secret_access_keySave the
credentials
file, and delete the .csv file that you downloaded in step 3.
Your shared credentials file is now configured on your local computer, and it's ready to be used with the AWS SDKs.