Class: OAuth2::Provider::AccessToken
- Inherits:
-
Object
- Object
- OAuth2::Provider::AccessToken
- Defined in:
- lib/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.
7 8 9 10 11 12 13 14 15 |
# File 'lib/oauth2/provider/access_token.rb', line 7 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.
5 6 7 |
# File 'lib/oauth2/provider/access_token.rb', line 5 def @authorization end |
Instance Method Details
#client ⇒ Object
17 18 19 |
# File 'lib/oauth2/provider/access_token.rb', line 17 def client valid? ? @authorization.client : nil end |
#owner ⇒ Object
21 22 23 |
# File 'lib/oauth2/provider/access_token.rb', line 21 def owner valid? ? @authorization.owner : nil end |
#response_headers ⇒ Object
25 26 27 28 29 30 |
# File 'lib/oauth2/provider/access_token.rb', line 25 def response_headers return {} if valid? = "OAuth realm='#{ Provider.realm }'" << ", error='#{ @error }'" unless @error == '' {'WWW-Authenticate' => } end |
#response_status ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/oauth2/provider/access_token.rb', line 32 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
41 42 43 |
# File 'lib/oauth2/provider/access_token.rb', line 41 def valid? @error.nil? end |