Module: RestCore::ClientOauth1
- Defined in:
- lib/rest-core/client_oauth1.rb
Instance Method Summary collapse
- #authorize!(opts = {}) ⇒ Object
- #authorize_url ⇒ Object
- #authorize_url!(opts = {}) ⇒ Object
- #authorized? ⇒ Boolean
- #data_json ⇒ Object
- #data_json=(json) ⇒ Object
- #oauth_callback ⇒ Object
- #oauth_callback=(uri) ⇒ Object
- #oauth_token ⇒ Object
- #oauth_token=(token) ⇒ Object
- #oauth_token_secret ⇒ Object
- #oauth_token_secret=(secret) ⇒ Object
Instance Method Details
#authorize!(opts = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/rest-core/client_oauth1.rb', line 21 def opts={} self.data = ParseQuery.parse_query( post(access_token_path, {}, {}, {:json_response => false}.merge(opts))) data['authorized'] = 'true' data end |
#authorize_url ⇒ Object
17 18 19 |
# File 'lib/rest-core/client_oauth1.rb', line 17 def url(, :oauth_token => oauth_token) end |
#authorize_url!(opts = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rest-core/client_oauth1.rb', line 9 def opts={} self.data = ParseQuery.parse_query( post(request_token_path, {}, {}, {:json_response => false}.merge(opts))) end |
#authorized? ⇒ Boolean
30 31 32 |
# File 'lib/rest-core/client_oauth1.rb', line 30 def !!(oauth_token && oauth_token_secret && data['authorized']) end |
#data_json ⇒ Object
34 35 36 |
# File 'lib/rest-core/client_oauth1.rb', line 34 def data_json Json.encode(data.merge('sig' => calculate_sig)) end |
#data_json=(json) ⇒ Object
38 39 40 41 42 |
# File 'lib/rest-core/client_oauth1.rb', line 38 def data_json= json self.data = check_sig_and_return_data(Json.decode(json)) rescue Json.const_get(:ParseError) self.data = nil end |
#oauth_callback ⇒ Object
56 57 58 |
# File 'lib/rest-core/client_oauth1.rb', line 56 def oauth_callback data['oauth_callback'] if data.kind_of?(Hash) end |
#oauth_callback=(uri) ⇒ Object
59 60 61 |
# File 'lib/rest-core/client_oauth1.rb', line 59 def oauth_callback= uri data['oauth_callback'] = uri if data.kind_of?(Hash) end |
#oauth_token ⇒ Object
44 45 46 |
# File 'lib/rest-core/client_oauth1.rb', line 44 def oauth_token data['oauth_token'] if data.kind_of?(Hash) end |
#oauth_token=(token) ⇒ Object
47 48 49 |
# File 'lib/rest-core/client_oauth1.rb', line 47 def oauth_token= token data['oauth_token'] = token if data.kind_of?(Hash) end |
#oauth_token_secret ⇒ Object
50 51 52 |
# File 'lib/rest-core/client_oauth1.rb', line 50 def oauth_token_secret data['oauth_token_secret'] if data.kind_of?(Hash) end |
#oauth_token_secret=(secret) ⇒ Object
53 54 55 |
# File 'lib/rest-core/client_oauth1.rb', line 53 def oauth_token_secret= secret data['oauth_token_secret'] = secret if data.kind_of?(Hash) end |