Class: Aws::LoginCredentials
- Inherits:
-
Object
- Object
- Aws::LoginCredentials
- Includes:
- CredentialProvider, RefreshingCredentials
- Defined in:
- gems/aws-sdk-core/lib/aws-sdk-core/login_credentials.rb
Overview
An auto-refreshing credential provider that retrieves credentials from
a cached login token. This class does NOT implement the AWS Sign-In
login flow - tokens must be generated separately by running aws login
from the AWS CLI/AWS Tools for PowerShell with the correct profile.
The LoginCredentials will auto-refresh the AWS credentials from AWS Sign-In.
# You must first run aws login --profile your-login-profile
login_credentials = Aws::LoginCredentials.new(login_session: 'my_login_session')
ec2 = Aws::EC2::Client.new(credentials: login_credentials)
If you omit the :client option, a new Signin::Client object will
be constructed with additional options that were provided.
Constant Summary
Constants included from RefreshingCredentials
RefreshingCredentials::ASYNC_EXPIRATION_LENGTH, RefreshingCredentials::CLIENT_EXCLUDE_OPTIONS, RefreshingCredentials::SYNC_EXPIRATION_LENGTH
Instance Attribute Summary collapse
-
#client ⇒ Signin::Client
readonly
Attributes included from CredentialProvider
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LoginCredentials
constructor
A new instance of LoginCredentials.
Methods included from RefreshingCredentials
Methods included from CredentialProvider
Constructor Details
#initialize(options = {}) ⇒ LoginCredentials
Returns a new instance of LoginCredentials.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/login_credentials.rb', line 27 def initialize( = {}) raise ArgumentError, 'Missing login_session' unless [:login_session] @login_session = .delete(:login_session) @client = [:client] unless @client client_opts = .reject { |key, _| CLIENT_EXCLUDE_OPTIONS.include?(key) } @client = Signin::Client.new(client_opts.merge(credentials: nil)) end @metrics = ['CREDENTIALS_LOGIN'] @async_refresh = true super end |
Instance Attribute Details
#client ⇒ Signin::Client (readonly)
42 43 44 |
# File 'gems/aws-sdk-core/lib/aws-sdk-core/login_credentials.rb', line 42 def client @client end |