Class: Admincredible::Resources::Oauth
Instance Attribute Summary
#client
Instance Method Summary
collapse
#config, #connection, #initialize
Instance Method Details
#access_token(oauth_verifier) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/admincredible/resources/Oauth.rb', line 34
def access_token(oauth_verifier)
params = {
:resource => 'oauth',
:task => 'access_token',
:oauth_token => config.token,
:oauth_verifier => oauth_verifier
}
= ROAuth.(config.oauth_options, config.url, params)
response = JSON.parse(Nestful.get(config.url, :params => params, :headers => {'Accept' => 'application/json', 'Authorization' => }))
return response unless response['status'] == 200
config.token = response['data']['access_token']['oauth_token']
config.token_secret = response['data']['access_token']['oauth_token_secret']
client.rebuild_connection
return response['data']['access_token']
end
|
#authorization_url ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/admincredible/resources/Oauth.rb', line 26
def authorization_url
url = config.url.gsub(config.direct_endpoint, config.main_endpoint)
url = URI.parse(url)
params = CGI.parse(url.query)
return ROAuth.sign_url(config.oauth_options, url.scheme + '://' + url.host + url.path, params.merge({:oauth_callback => config.oauth_callback}))
end
|
#register ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/admincredible/resources/Oauth.rb', line 4
def register
response = client.jget('oauth', 'register')
return response unless response['status'] == 200
config.consumer_key = response['data']['osr_consumer_key']
config.consumer_secret = response['data']['osr_consumer_secret']
client.rebuild_connection
return response['data']
end
|
#request_token ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/admincredible/resources/Oauth.rb', line 15
def request_token
response = client.jget('oauth', 'request_token')
return response unless response['status'] == 200
config.token = response['data']['request_token']['oauth_token']
config.token_secret = response['data']['request_token']['oauth_token_secret']
client.rebuild_connection
return response['data']['request_token']
end
|