Class: Doorkeeper::OAuth::Client::Credentials

Inherits:
Struct
  • Object
show all
Defined in:
lib/doorkeeper/oauth/client/credentials.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#secretObject

Returns the value of attribute secret

Returns:

  • (Object)

    the current value of secret


6
7
8
# File 'lib/doorkeeper/oauth/client/credentials.rb', line 6

def secret
  @secret
end

#uidObject

Returns the value of attribute uid

Returns:

  • (Object)

    the current value of uid


6
7
8
# File 'lib/doorkeeper/oauth/client/credentials.rb', line 6

def uid
  @uid
end

Class Method Details

.from_basic(request) ⇒ Object


20
21
22
23
24
25
# File 'lib/doorkeeper/oauth/client/credentials.rb', line 20

def from_basic(request)
  authorization = request.authorization
  if authorization.present? && authorization =~ /^Basic (.*)/m
    Base64.decode64(Regexp.last_match(1)).split(/:/, 2)
  end
end

.from_params(request) ⇒ Object


16
17
18
# File 'lib/doorkeeper/oauth/client/credentials.rb', line 16

def from_params(request)
  request.parameters.values_at(:client_id, :client_secret)
end

.from_request(request, *credentials_methods) ⇒ Object


8
9
10
11
12
13
14
# File 'lib/doorkeeper/oauth/client/credentials.rb', line 8

def from_request(request, *credentials_methods)
  credentials_methods.inject(nil) do |_, method|
    method = self.method(method) if method.is_a?(Symbol)
    credentials = Credentials.new(*method.call(request))
    break credentials if credentials.present?
  end
end