Class: Songkick::OAuth2::Provider::AccessToken
- Inherits:
-
Object
- Object
- Songkick::OAuth2::Provider::AccessToken
- Defined in:
- lib/songkick/oauth2/provider/access_token.rb
Instance Attribute Summary collapse
-
#authorization ⇒ Object
readonly
Returns the value of attribute authorization.
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(resource_owner = nil, scopes = [], access_token = nil, error = nil) ⇒ AccessToken
constructor
A new instance of AccessToken.
- #owner ⇒ Object
- #response_headers ⇒ Object
- #response_status ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(resource_owner = nil, scopes = [], access_token = nil, error = nil) ⇒ AccessToken
Returns a new instance of AccessToken.
8 9 10 11 12 13 14 15 16 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 8 def initialize(resource_owner = nil, scopes = [], access_token = nil, error = nil) @resource_owner = resource_owner @scopes = scopes @access_token = access_token @error = error && INVALID_REQUEST (access_token, error) validate! end |
Instance Attribute Details
#authorization ⇒ Object (readonly)
Returns the value of attribute authorization.
6 7 8 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 6 def @authorization end |
Instance Method Details
#client ⇒ Object
18 19 20 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 18 def client valid? ? @authorization.client : nil end |
#owner ⇒ Object
22 23 24 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 22 def owner valid? ? @authorization.owner : nil end |
#response_headers ⇒ Object
26 27 28 29 30 31 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 26 def response_headers return {} if valid? = "OAuth realm='#{ Provider.realm }'" << ", error='#{ @error }'" unless @error == '' {'WWW-Authenticate' => } end |
#response_status ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 33 def response_status case @error when INVALID_REQUEST, INVALID_TOKEN, EXPIRED_TOKEN then 401 when INSUFFICIENT_SCOPE then 403 when '' then 401 else 200 end end |
#valid? ⇒ Boolean
42 43 44 |
# File 'lib/songkick/oauth2/provider/access_token.rb', line 42 def valid? @error.nil? end |