Class: Doorkeeper::OAuth::PasswordAccessTokenRequest
- Inherits:
-
Object
- Object
- Doorkeeper::OAuth::PasswordAccessTokenRequest
- Includes:
- Helpers, Validations
- Defined in:
- lib/doorkeeper/oauth/password_access_token_request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#resource_owner ⇒ Object
Returns the value of attribute resource_owner.
-
#server ⇒ Object
Returns the value of attribute server.
Attributes included from Validations
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorize ⇒ Object
-
#initialize(server, client, resource_owner, parameters = {}) ⇒ PasswordAccessTokenRequest
constructor
A new instance of PasswordAccessTokenRequest.
- #scopes ⇒ Object
- #valid? ⇒ Boolean
Methods included from Validations
Constructor Details
#initialize(server, client, resource_owner, parameters = {}) ⇒ PasswordAccessTokenRequest
Returns a new instance of PasswordAccessTokenRequest.
12 13 14 15 16 17 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 12 def initialize(server, client, resource_owner, parameters = {}) @server = server @resource_owner = resource_owner @client = client @original_scopes = parameters[:scope] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 10 def client @client end |
#resource_owner ⇒ Object
Returns the value of attribute resource_owner.
10 11 12 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 10 def resource_owner @resource_owner end |
#server ⇒ Object
Returns the value of attribute server.
10 11 12 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 10 def server @server end |
Instance Method Details
#access_token ⇒ Object
33 34 35 36 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 33 def access_token return unless client.present? && resource_owner.present? @access_token ||= Doorkeeper::AccessToken.matching_token_for client, resource_owner.id, scopes end |
#authorize ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 19 def validate @response = if valid? find_or_create_access_token TokenResponse.new access_token else ErrorResponse.from_request self end end |
#scopes ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 38 def scopes @scopes ||= if @original_scopes.present? Doorkeeper::OAuth::Scopes.from_string(@original_scopes) else server.default_scopes end end |
#valid? ⇒ Boolean
29 30 31 |
# File 'lib/doorkeeper/oauth/password_access_token_request.rb', line 29 def valid? self.error.nil? end |