Class: OAuth::Server

Inherits:
Object
  • Object
show all
Includes:
Key
Defined in:
lib/oauth/server.rb

Overview

This is mainly used to create consumer credentials and can pretty much be ignored if you want to create your own

Constant Summary collapse

@@server_paths =
{
  :request_token_path=>"/oauth/request_token",
  :authorize_path=>"/oauth/authorize",
  :access_token_path=>"/oauth/access_token"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Key

#escape, #generate_key

Constructor Details

#initialize(base_url, paths = {}) ⇒ Server

Create a new server instance



13
14
15
16
# File 'lib/oauth/server.rb', line 13

def initialize(base_url,paths={})
  @base_url=base_url
  @paths=@@server_paths.merge(paths)
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



5
6
7
# File 'lib/oauth/server.rb', line 5

def base_url
  @base_url
end

Instance Method Details

#access_token_pathObject



55
56
57
# File 'lib/oauth/server.rb', line 55

def access_token_path
  @paths[:access_token_path]
end

#access_token_urlObject



59
60
61
# File 'lib/oauth/server.rb', line 59

def access_token_url
  base_url+access_token_path
end

#authorize_pathObject



47
48
49
# File 'lib/oauth/server.rb', line 47

def authorize_path
  @paths[:authorize_path]
end

#authorize_urlObject



51
52
53
# File 'lib/oauth/server.rb', line 51

def authorize_url
  base_url+authorize_path
end

#create_consumerObject

mainly for testing purposes



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/oauth/server.rb', line 27

def create_consumer
  credentials=generate_credentials
  Consumer.new( {
    :site=>base_url,
    :consumer_key=>credentials[0],
    :consumer_secret=>credentials[1],
    :request_token_path=>request_token_path,
    :authorize_path=>authorize_path,
    :access_token_path=>access_token_path
  })
end

#generate_consumer_credentials(params = {}) ⇒ Object



22
23
24
# File 'lib/oauth/server.rb', line 22

def generate_consumer_credentials(params={})
  ConsumerCredentials.new( *generate_credentials)
end

#generate_credentialsObject



18
19
20
# File 'lib/oauth/server.rb', line 18

def generate_credentials()
  [generate_key(16),generate_key]
end

#request_token_pathObject



39
40
41
# File 'lib/oauth/server.rb', line 39

def request_token_path
  @paths[:request_token_path]
end

#request_token_urlObject



43
44
45
# File 'lib/oauth/server.rb', line 43

def request_token_url
  base_url+request_token_path
end