Class: Akeneo::AuthorizationService
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- Akeneo::AuthorizationService
- Defined in:
- lib/akeneo/authorization_service.rb
Constant Summary collapse
- REFRESH_RATE_IN_SECONDS =
2000
Constants inherited from ServiceBase
ServiceBase::API_VERSION, ServiceBase::DEFAULT_PAGINATION_LIMIT, ServiceBase::DEFAULT_PAGINATION_TYPE
Constants included from Cache
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#last_refresh ⇒ Object
Returns the value of attribute last_refresh.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #authorize!(client_id:, secret:, username:, password:) ⇒ Object
- #fresh_access_token ⇒ Object
-
#initialize(url:) ⇒ AuthorizationService
constructor
A new instance of AuthorizationService.
Methods included from Cache
disabled=, #get_request, prepended
Constructor Details
#initialize(url:) ⇒ AuthorizationService
Returns a new instance of AuthorizationService.
11 12 13 |
# File 'lib/akeneo/authorization_service.rb', line 11 def initialize(url:) @url = url end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/akeneo/authorization_service.rb', line 9 def access_token @access_token end |
#last_refresh ⇒ Object
Returns the value of attribute last_refresh.
9 10 11 |
# File 'lib/akeneo/authorization_service.rb', line 9 def last_refresh @last_refresh end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
9 10 11 |
# File 'lib/akeneo/authorization_service.rb', line 9 def refresh_token @refresh_token end |
Instance Method Details
#authorize!(client_id:, secret:, username:, password:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/akeneo/authorization_service.rb', line 15 def (client_id:, secret:, username:, password:) @client_id = client_id @secret = secret = { body: (username, password), headers: json_headers.merge() } response = HTTParty.post("#{@url}/api/oauth/v1/token", ) store_tokens!(response) response end |
#fresh_access_token ⇒ Object
27 28 29 30 |
# File 'lib/akeneo/authorization_service.rb', line 27 def fresh_access_token refresh! @access_token end |