Class: Warden::Cognito::CognitoClient

Inherits:
Object
  • Object
show all
Includes:
HasUserPoolIdentifier
Defined in:
lib/warden/cognito/cognito_client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasUserPoolIdentifier

included, #pool_identifier, #user_pool=

Class Method Details

.scope(pool_identifier) ⇒ Object



30
31
32
33
34
# File 'lib/warden/cognito/cognito_client.rb', line 30

def scope(pool_identifier)
  new.tap do |client|
    client.user_pool = pool_identifier || default_pool_identifier
  end
end

Instance Method Details

#fetch(access_token) ⇒ Object



8
9
10
# File 'lib/warden/cognito/cognito_client.rb', line 8

def fetch(access_token)
  client.get_user(access_token: access_token)
end

#initiate_auth(email, password) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/warden/cognito/cognito_client.rb', line 12

def initiate_auth(email, password)
  client.initiate_auth(
    client_id: user_pool.client_id,
    auth_flow: 'USER_PASSWORD_AUTH',
    auth_parameters: {
      'USERNAME' => email,
      'PASSWORD' => password
    }
  )
end