Struct: credentials.SharedCredentialsProvider

import "../ibm-cos-sdk-go/aws/credentials"

Overview

A SharedCredentialsProvider retrieves access key pair (access key ID, secret access key, and session token if present) credentials from the current user's home directory, and keeps track if those credentials are expired.

Profile ini file example: $HOME/.aws/credentials

Implemented Interfaces

s3crypto.Cipher, credentials.Provider, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Structure Field Summary collapse

Method Summary collapse

Structure Field Details

Filename string

Path to the shared credentials file.

If empty will look for “AWS_SHARED_CREDENTIALS_FILE” env variable. If the env value is empty will default to current user's home directory. Linux/OSX: “$HOME/.aws/credentials” Windows: “%USERPROFILE%.awscredentials”

Profile string

AWS Profile to extract credentials from the shared credentials file. If empty will default to environment variable “AWS_PROFILE” or “default” if environment variable is also not set.

Method Details

func (p *SharedCredentialsProvider) IsExpired() bool

IsExpired returns if the shared credentials have expired.



71
72
73
// File 'aws/credentials/shared_credentials_provider.go', line 71

func (p *SharedCredentialsProvider) IsExpired() bool { return !p.retrieved }

func (p *SharedCredentialsProvider) Retrieve() (Value, error)

Retrieve reads and extracts the shared credentials from the current users home directory.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// File 'aws/credentials/shared_credentials_provider.go', line 53

func (p *SharedCredentialsProvider) Retrieve() (Value, error) { p.retrieved = false filename, err := p.filename() if err != nil { return Value{ProviderName: SharedCredsProviderName}, err } creds, err := loadProfile(filename, p.profile()) if err != nil { return Value{ProviderName: SharedCredsProviderName}, err } p.retrieved = true return creds, nil }