Class: Doorkeeper::OAuth::BaseRequest
- Inherits:
-
Object
- Object
- Doorkeeper::OAuth::BaseRequest
- Includes:
- Validations
- Defined in:
- lib/doorkeeper/oauth/base_request.rb
Direct Known Subclasses
AuthorizationCodeRequest, ClientCredentialsRequest, PasswordAccessTokenRequest, RefreshTokenRequest
Instance Attribute Summary collapse
-
#grant_type ⇒ Object
readonly
Returns the value of attribute grant_type.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Attributes included from Validations
Instance Method Summary collapse
- #after_successful_response ⇒ Object
- #authorize ⇒ Object
- #before_successful_response ⇒ Object
- #find_or_create_access_token(client, resource_owner, scopes, custom_attributes, server) ⇒ Object
- #scopes ⇒ Object
Methods included from Validations
Instance Attribute Details
#grant_type ⇒ Object (readonly)
Returns the value of attribute grant_type.
8 9 10 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 8 def grant_type @grant_type end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 8 def server @server end |
Instance Method Details
#after_successful_response ⇒ Object
49 50 51 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 49 def after_successful_response Doorkeeper.config.after_successful_strategy_response.call(self, @response) end |
#authorize ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 12 def if valid? before_successful_response @response = TokenResponse.new(access_token) after_successful_response @response elsif error == Errors::InvalidRequest @response = InvalidRequestResponse.from_request(self) else @response = ErrorResponse.from_request(self) end end |
#before_successful_response ⇒ Object
45 46 47 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 45 def before_successful_response Doorkeeper.config.before_successful_strategy_response.call(self) end |
#find_or_create_access_token(client, resource_owner, scopes, custom_attributes, server) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 29 def find_or_create_access_token(client, resource_owner, scopes, custom_attributes, server) context = Authorization::Token.build_context(client, grant_type, scopes, resource_owner) application = client.is_a?(Doorkeeper.config.application_model) ? client : client&.application token_attributes = { application: application, resource_owner: resource_owner, scopes: scopes, expires_in: Authorization::Token.access_token_expires_in(server, context), use_refresh_token: Authorization::Token.refresh_token_enabled?(server, context), } @access_token = Doorkeeper.config.access_token_model.find_or_create_for(**token_attributes.merge(custom_attributes)) end |
#scopes ⇒ Object
25 26 27 |
# File 'lib/doorkeeper/oauth/base_request.rb', line 25 def scopes @scopes ||= build_scopes end |