go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Way to set API's credentials
 
Subject: Way to set API's credentials
Author: AwsEC2
In response to: API -- Connection to AWS
Posted on: 10/04/2019 01:26:08 AM


Way#1 Via explicitly input
Example

    BasicAWSCredentials awsCreds = new BasicAWSCredentials(
        "JKT3AKUV3DI8VXCRMNQ2",                    // "access_key_id", 
        "H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM" // "secret_acess_key"
    );	  
	    	  
    AmazonS3 s3Client = AmazonS3ClientBuilder.standard().
	  		  withRegion(Regions.US_EAST_1).
	  		  withCredentials(new AWSStaticCredentialsProvider(awsCreds)).
	  		  build();	    	  




Way#1 Via loading order
  • Environment Variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • Java System Properties: aws.accessKeyId and aws.secretKey
  • From file with environment variable: AWS_CREDENTIAL_PROFILES_FILE=path/to/file

    aws_access_key_id={YOUR_ACCESS_KEY_ID}
    aws_secret_access_key={YOUR_SECRET_ACCESS_KEY}
    


    Example
        System.setProperty("aws.accessKeyId", "JKT3AKUV3DI8VXCRMNQ2");
        System.setProperty("aws.secretKey", "H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM");
    	    	  
        AmazonS3 s3Client = AmazonS3ClientBuilder.standard().
    	  		  withRegion(Regions.US_EAST_1).
    	  		  build();	    	  
    



     

    > On 10/04/2019 01:23:22 AM AwsEC2 wrote:

    When a user want to connect to a server like AWS, he/she needs USERNAME+PASSWORD to authenticate himself/herself to the server before getting any protected information. The same logic applies here when a API/robot is trying to connect to AWS -- a service account is needed for API calling. The service account consists of:
        access_key_id: JKT3AKUV3DI8VXCRMNQ2
    secret_access_key: H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM
    


    Here, access_key_id is like USERNAME which is public and secret_access_key is like PASSWORD which should be kept secret.





    References:

  •  


     
    Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.