Class: OAuth2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/oauth20/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
# File 'lib/oauth20/client.rb', line 5

def initialize(name, options = {})
  @name = name
  @client_type = 'confidential'
  @key = options[:key] || OAuth2::Utils.generate_key
  @secret = options[:secret] || OAuth2::Utils.generate_key
  @redirect_uri = options[:redirect_uri] || nil
end

Instance Attribute Details

#client_typeObject (readonly)

Returns the value of attribute client_type.



3
4
5
# File 'lib/oauth20/client.rb', line 3

def client_type
  @client_type
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/oauth20/client.rb', line 3

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/oauth20/client.rb', line 3

def name
  @name
end

#redirect_uriObject (readonly)

Returns the value of attribute redirect_uri.



3
4
5
# File 'lib/oauth20/client.rb', line 3

def redirect_uri
  @redirect_uri
end

#secretObject (readonly)

Returns the value of attribute secret.



3
4
5
# File 'lib/oauth20/client.rb', line 3

def secret
  @secret
end

Class Method Details

.allObject



25
26
27
# File 'lib/oauth20/client.rb', line 25

def self.all
  OAuth2::Storage.instance.client_all()
end

.find_by_key(key) ⇒ Object



17
18
19
# File 'lib/oauth20/client.rb', line 17

def self.find_by_key(key)
  OAuth2::Storage.instance.client_find_by_key(key)
end

Instance Method Details

#create_access_token(user) ⇒ Object



13
14
15
# File 'lib/oauth20/client.rb', line 13

def create_access_token(user)
  OAuth2::AccessToken.new({:client_key => key, :user_id => user.id})
end

#saveObject



21
22
23
# File 'lib/oauth20/client.rb', line 21

def save
  OAuth2::Storage.instance.client_save(self)
end