Class: OAuth::Server

Inherits:
Object show all
Includes:
Helper
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 Helper

#escape, #generate_key, #generate_timestamp, #normalize, #parse_header, #stringify_keys, #unescape

Constructor Details

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

Create a new server instance



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

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.



8
9
10
# File 'lib/oauth/server.rb', line 8

def base_url
  @base_url
end

Instance Method Details

#access_token_pathObject



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

def access_token_path
  @paths[:access_token_path]
end

#access_token_urlObject



62
63
64
# File 'lib/oauth/server.rb', line 62

def access_token_url
  base_url + access_token_path
end

#authorize_pathObject



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

def authorize_path
  @paths[:authorize_path]
end

#authorize_urlObject



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

def authorize_url
  base_url + authorize_path
end

#create_consumerObject

mainly for testing purposes



31
32
33
34
35
36
37
38
39
40
# File 'lib/oauth/server.rb', line 31

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

#generate_consumer_credentials(params = {}) ⇒ Object



26
27
28
# File 'lib/oauth/server.rb', line 26

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

#generate_credentialsObject



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

def generate_credentials
  [generate_key(16), generate_key]
end

#request_token_pathObject



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

def request_token_path
  @paths[:request_token_path]
end

#request_token_urlObject



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

def request_token_url
  base_url + request_token_path
end