Class: Zara4::API::Communication::Authentication::UserAuthenticator
- Inherits:
-
Authenticator
- Object
- Authenticator
- Zara4::API::Communication::Authentication::UserAuthenticator
- Defined in:
- lib/zara4/api/communication/authentication/user_authenticator.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#acquire_access_token ⇒ Object
Acquire an AccessToken using this UserAuthenticator.
-
#initialize(client_id, client_secret, username, password) ⇒ UserAuthenticator
constructor
Constructor.
Methods inherited from Authenticator
#with_image_processing, #with_usage
Constructor Details
#initialize(client_id, client_secret, username, password) ⇒ UserAuthenticator
Constructor
11 12 13 14 15 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 11 def initialize(client_id, client_secret, username, password) super.initialize(client_id, client_secret) @username = username @password = password end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 5 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
5 6 7 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 5 def client_secret @client_secret end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 5 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 5 def username @username end |
Instance Method Details
#acquire_access_token ⇒ Object
Acquire an AccessToken using this UserAuthenticator.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/zara4/api/communication/authentication/user_authenticator.rb', line 21 def acquire_access_token grant = Zara4::API::Communication::Grant::ClientCredentialsGrantRequest.new(@client_id, @clint_secret, @scopes) tokens = grant.getTokens() access_token = tokens['access_token'] refresh_token = tokens['refresh_token'] expires_at = Zara4::API::Communication::Util::calculate_expiry_time(tokens['expires_in']) return Zara4::API::Communication::AccessToken::RefreshableAccessToken.new(@client_id, @client_secret, access_token, expires_at, refresh_token) end |