Class: Polar::Authentication::OATAuth
- Inherits:
-
Object
- Object
- Polar::Authentication::OATAuth
- Defined in:
- lib/polar/authentication.rb
Overview
Organization Access Token authentication
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(access_token) ⇒ OATAuth
constructor
A new instance of OATAuth.
- #valid? ⇒ Boolean
Constructor Details
#initialize(access_token) ⇒ OATAuth
Returns a new instance of OATAuth.
9 10 11 12 |
# File 'lib/polar/authentication.rb', line 9 def initialize(access_token) @access_token = access_token validate_token! end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
7 8 9 |
# File 'lib/polar/authentication.rb', line 7 def access_token @access_token end |
Instance Method Details
#headers ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/polar/authentication.rb', line 14 def headers { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json', 'Accept' => 'application/json' } end |
#valid? ⇒ Boolean
22 23 24 |
# File 'lib/polar/authentication.rb', line 22 def valid? !access_token.nil? && !access_token.empty? && access_token.start_with?('polar_oat_') end |