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, escape, generate_key, generate_timestamp, normalize, normalize_nested_query, parse_header, stringify_keys, unescape
Constructor Details
#initialize(base_url, paths = {}) ⇒ Server
Create a new server instance
19
20
21
22
|
# File 'lib/oauth/server.rb', line 19
def initialize(base_url, paths = {})
@base_url = base_url
@paths = @@server_paths.merge(paths)
end
|
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
10
11
12
|
# File 'lib/oauth/server.rb', line 10
def base_url
@base_url
end
|
Instance Method Details
#access_token_path ⇒ Object
60
61
62
|
# File 'lib/oauth/server.rb', line 60
def access_token_path
@paths[:access_token_path]
end
|
#access_token_url ⇒ Object
64
65
66
|
# File 'lib/oauth/server.rb', line 64
def access_token_url
base_url + access_token_path
end
|
#authorize_path ⇒ Object
52
53
54
|
# File 'lib/oauth/server.rb', line 52
def authorize_path
@paths[:authorize_path]
end
|
#authorize_url ⇒ Object
56
57
58
|
# File 'lib/oauth/server.rb', line 56
def authorize_url
base_url + authorize_path
end
|
#create_consumer ⇒ Object
mainly for testing purposes
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/oauth/server.rb', line 33
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
28
29
30
|
# File 'lib/oauth/server.rb', line 28
def generate_consumer_credentials(_params = {})
Consumer.new(*generate_credentials)
end
|
#generate_credentials ⇒ Object
24
25
26
|
# File 'lib/oauth/server.rb', line 24
def generate_credentials
[generate_key(16), generate_key]
end
|
#request_token_path ⇒ Object
44
45
46
|
# File 'lib/oauth/server.rb', line 44
def request_token_path
@paths[:request_token_path]
end
|
#request_token_url ⇒ Object
48
49
50
|
# File 'lib/oauth/server.rb', line 48
def request_token_url
base_url + request_token_path
end
|