Class: Doorkeeper::OAuth::CodeResponse
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Doorkeeper::OAuth::CodeResponse
- Includes:
- Helpers
- Defined in:
- lib/doorkeeper/oauth/code_response.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#pre_auth ⇒ Object
readonly
Returns the value of attribute pre_auth.
-
#response_on_fragment ⇒ Object
readonly
Returns the value of attribute response_on_fragment.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(pre_auth, auth, options = {}) ⇒ CodeResponse
constructor
A new instance of CodeResponse.
- #issued_token ⇒ Object
- #redirect_uri ⇒ Object
- #redirectable? ⇒ Boolean
Methods inherited from BaseResponse
#description, #headers, #status
Constructor Details
#initialize(pre_auth, auth, options = {}) ⇒ CodeResponse
Returns a new instance of CodeResponse.
10 11 12 13 14 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 10 def initialize(pre_auth, auth, = {}) @pre_auth = pre_auth @auth = auth @response_on_fragment = [:response_on_fragment] end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
8 9 10 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 8 def auth @auth end |
#pre_auth ⇒ Object (readonly)
Returns the value of attribute pre_auth.
8 9 10 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 8 def pre_auth @pre_auth end |
#response_on_fragment ⇒ Object (readonly)
Returns the value of attribute response_on_fragment.
8 9 10 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 8 def response_on_fragment @response_on_fragment end |
Instance Method Details
#body ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 24 def body if auth.try(:access_token?) { access_token: auth.token.plaintext_token, token_type: auth.token.token_type, expires_in: auth.token.expires_in_seconds, state: pre_auth.state, } elsif auth.try(:access_grant?) { code: auth.token.plaintext_token, state: pre_auth.state, } end end |
#issued_token ⇒ Object
20 21 22 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 20 def issued_token auth.token end |
#redirect_uri ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 40 def redirect_uri if URIChecker.oob_uri?(pre_auth.redirect_uri) auth.oob_redirect elsif response_on_fragment Authorization::URIBuilder.uri_with_fragment(pre_auth.redirect_uri, body) else Authorization::URIBuilder.uri_with_query(pre_auth.redirect_uri, body) end end |
#redirectable? ⇒ Boolean
16 17 18 |
# File 'lib/doorkeeper/oauth/code_response.rb', line 16 def redirectable? true end |