Class: Signet::OAuth1::Client
- Inherits:
-
Object
- Object
- Signet::OAuth1::Client
- Defined in:
- lib/signet/oauth_1/client.rb
Instance Method Summary collapse
-
#authorization_uri(options = {}) ⇒ Addressable::URI
Returns the authorization URI that the user should be redirected to.
-
#authorization_uri=(new_authorization_uri) ⇒ Object
Sets the authorization URI for this client.
-
#callback ⇒ String
Returns the callback for this client.
-
#callback=(new_callback) ⇒ Object
Sets the callback for this client.
-
#client_credential ⇒ Signet::OAuth1::Credential
(also: #consumer_token)
Returns the client credential for this client.
-
#client_credential=(new_client_credential) ⇒ Object
(also: #consumer_token=)
Sets the client credential for this client.
-
#client_credential_key ⇒ String
(also: #consumer_key)
Returns the client credential key for this client.
-
#client_credential_key=(new_client_credential_key) ⇒ Object
(also: #consumer_key=)
Sets the client credential key for this client.
-
#client_credential_secret ⇒ String
(also: #consumer_secret)
Returns the client credential secret for this client.
-
#client_credential_secret=(new_client_credential_secret) ⇒ Object
(also: #consumer_secret=)
Sets the client credential secret for this client.
-
#fetch_protected_resource(options = {}) ⇒ Array
Transmits a request for a protected resource.
-
#fetch_temporary_credential(options = {}) ⇒ Signet::OAuth1::Credential
(also: #fetch_request_token)
Transmits a request for a temporary credential.
-
#fetch_temporary_credential!(options = {}) ⇒ Signet::OAuth1::Credential
(also: #fetch_request_token!)
Transmits a request for a temporary credential.
-
#fetch_token_credential(options = {}) ⇒ Signet::OAuth1::Credential
(also: #fetch_access_token)
Transmits a request for a token credential.
-
#fetch_token_credential!(options = {}) ⇒ Signet::OAuth1::Credential
(also: #fetch_access_token!)
Transmits a request for a token credential.
-
#generate_authenticated_request(options = {}) ⇒ Array
Generates an authenticated request for protected resources.
-
#generate_temporary_credential_request(options = {}) ⇒ Array
(also: #generate_request_token_request)
Generates a request for temporary credentials.
-
#generate_token_credential_request(options = {}) ⇒ Array
(also: #generate_access_token_request)
Generates a request for token credentials.
-
#initialize(options = {}) ⇒ Client
constructor
Creates an OAuth 1.0 client.
-
#temporary_credential ⇒ Signet::OAuth1::Credential
(also: #request_token)
Returns the temporary credential for this client.
-
#temporary_credential=(new_temporary_credential) ⇒ Object
(also: #request_token=)
Sets the temporary credential for this client.
-
#temporary_credential_key ⇒ String
(also: #request_token_key)
Returns the temporary credential key for this client.
-
#temporary_credential_key=(new_temporary_credential_key) ⇒ Object
(also: #request_token_key=)
Sets the temporary credential key for this client.
-
#temporary_credential_secret ⇒ String
(also: #request_token_secret)
Returns the temporary credential secret for this client.
-
#temporary_credential_secret=(new_temporary_credential_secret) ⇒ Object
(also: #request_token_secret=)
Sets the temporary credential secret for this client.
-
#temporary_credential_uri ⇒ Addressable::URI
(also: #request_token_uri)
Returns the temporary credentials URI for this client.
-
#temporary_credential_uri=(new_temporary_credential_uri) ⇒ Object
(also: #request_token_uri=)
Sets the temporary credentials URI for this client.
-
#token_credential ⇒ Signet::OAuth1::Credential
(also: #access_token)
Returns the token credential for this client.
-
#token_credential=(new_token_credential) ⇒ Object
(also: #access_token=)
Sets the token credential for this client.
-
#token_credential_key ⇒ String
(also: #access_token_key)
Returns the token credential key for this client.
-
#token_credential_key=(new_token_credential_key) ⇒ Object
(also: #access_token_key=)
Sets the token credential key for this client.
-
#token_credential_secret ⇒ String
(also: #access_token_secret)
Returns the token credential secret for this client.
-
#token_credential_secret=(new_token_credential_secret) ⇒ Object
(also: #access_token_secret=)
Sets the token credential secret for this client.
-
#token_credential_uri ⇒ Addressable::URI
(also: #access_token_uri)
Returns the token credential URI for this client.
-
#token_credential_uri=(new_token_credential_uri) ⇒ Object
(also: #access_token_uri=)
Sets the token credential URI for this client.
-
#two_legged ⇒ TrueClass, FalseClass
Returns whether the client is in two-legged mode.
-
#two_legged=(new_two_legged) ⇒ Object
Sets the client for two-legged mode.
Constructor Details
#initialize(options = {}) ⇒ Client
Creates an OAuth 1.0 client.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/signet/oauth_1/client.rb', line 57 def initialize(={}) self.temporary_credential_uri = [:temporary_credential_uri] self. = [:authorization_uri] self.token_credential_uri = [:token_credential_uri] # Technically... this would allow you to pass in a :client key... # But that would be weird. Don't do that. self.client_credential_key = Signet::OAuth1.extract_credential_key_option(:client, ) self.client_credential_secret = Signet::OAuth1.extract_credential_secret_option(:client, ) self.temporary_credential_key = Signet::OAuth1.extract_credential_key_option(:temporary, ) self.temporary_credential_secret = Signet::OAuth1.extract_credential_secret_option(:temporary, ) self.token_credential_key = Signet::OAuth1.extract_credential_key_option(:token, ) self.token_credential_secret = Signet::OAuth1.extract_credential_secret_option(:token, ) self.callback = [:callback] self.two_legged = [:two_legged] || false end |
Instance Method Details
#authorization_uri(options = {}) ⇒ Addressable::URI
Returns the authorization URI that the user should be redirected to.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/signet/oauth_1/client.rb', line 111 def (={}) = .merge( :temporary_credential_key => self.temporary_credential_key, :callback => self.callback ) return nil if @authorization_uri == nil return Addressable::URI.parse( ::Signet::OAuth1.( @authorization_uri, ) ) end |
#authorization_uri=(new_authorization_uri) ⇒ Object
Sets the authorization URI for this client.
129 130 131 132 133 134 135 136 137 |
# File 'lib/signet/oauth_1/client.rb', line 129 def () if != nil = Addressable::URI.parse() @authorization_uri = else @authorization_uri = nil end end |
#callback ⇒ String
Returns the callback for this client.
468 469 470 |
# File 'lib/signet/oauth_1/client.rb', line 468 def callback return @callback || ::Signet::OAuth1::OUT_OF_BAND end |
#callback=(new_callback) ⇒ Object
Sets the callback for this client.
477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/signet/oauth_1/client.rb', line 477 def callback=(new_callback) if new_callback != nil if !new_callback.respond_to?(:to_str) raise TypeError, "Can't convert #{new_callback.class} into String." end new_callback = new_callback.to_str @callback = new_callback else @callback = nil end end |
#client_credential ⇒ Signet::OAuth1::Credential Also known as: consumer_token
Returns the client credential for this client.
171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/signet/oauth_1/client.rb', line 171 def client_credential if self.client_credential_key && self.client_credential_secret return ::Signet::OAuth1::Credential.new( self.client_credential_key, self.client_credential_secret ) elsif !self.client_credential_key && !self.client_credential_secret return nil else raise ArgumentError, "The client credential key and secret must be set." end end |
#client_credential=(new_client_credential) ⇒ Object Also known as: consumer_token=
Sets the client credential for this client.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/signet/oauth_1/client.rb', line 191 def client_credential=(new_client_credential) if new_client_credential != nil if !new_client_credential.kind_of?(::Signet::OAuth1::Credential) raise TypeError, "Expected Signet::OAuth1::Credential, " + "got #{new_client_credential.class}." end @client_credential_key = new_client_credential.key @client_credential_secret = new_client_credential.secret else @client_credential_key = nil @client_credential_secret = nil end end |
#client_credential_key ⇒ String Also known as: consumer_key
Returns the client credential key for this client.
211 212 213 |
# File 'lib/signet/oauth_1/client.rb', line 211 def client_credential_key return @client_credential_key end |
#client_credential_key=(new_client_credential_key) ⇒ Object Also known as: consumer_key=
Sets the client credential key for this client.
221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/signet/oauth_1/client.rb', line 221 def client_credential_key=(new_client_credential_key) if new_client_credential_key != nil if !new_client_credential_key.respond_to?(:to_str) raise TypeError, "Can't convert #{new_client_credential_key.class} into String." end new_client_credential_key = new_client_credential_key.to_str @client_credential_key = new_client_credential_key else @client_credential_key = nil end end |
#client_credential_secret ⇒ String Also known as: consumer_secret
Returns the client credential secret for this client.
239 240 241 |
# File 'lib/signet/oauth_1/client.rb', line 239 def client_credential_secret return @client_credential_secret end |
#client_credential_secret=(new_client_credential_secret) ⇒ Object Also known as: consumer_secret=
Sets the client credential secret for this client.
249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/signet/oauth_1/client.rb', line 249 def client_credential_secret=(new_client_credential_secret) if new_client_credential_secret != nil if !new_client_credential_secret.respond_to?(:to_str) raise TypeError, "Can't convert #{new_client_credential_secret.class} " + "into String." end new_client_credential_secret = new_client_credential_secret.to_str @client_credential_secret = new_client_credential_secret else @client_credential_secret = nil end end |
#fetch_protected_resource(options = {}) ⇒ Array
Transmits a request for a protected resource.
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
# File 'lib/signet/oauth_1/client.rb', line 983 def fetch_protected_resource(={}) [:connection] ||= Faraday.default_connection request = self.generate_authenticated_request() request_env = request.to_env([:connection]) response = [:connection].app.call(request_env) if response.status.to_i == 401 # When accessing a protected resource, we only want to raise an # error for 401 responses. = 'Authorization failed.' if response.body.to_s.strip.length > 0 += " Server message:\n#{response.body.to_s.strip}" end raise ::Signet::AuthorizationError.new( , :request => request, :response => response ) else return response end end |
#fetch_temporary_credential(options = {}) ⇒ Signet::OAuth1::Credential Also known as: fetch_request_token
Transmits a request for a temporary credential. This method does not have side-effects within the client.
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
# File 'lib/signet/oauth_1/client.rb', line 602 def fetch_temporary_credential(={}) [:connection] ||= Faraday.default_connection request = self.generate_temporary_credential_request() request_env = request.to_env([:connection]) response = [:connection].app.call(request_env) if response.status.to_i == 200 return ::Signet::OAuth1.parse_form_encoded_credentials(response.body) elsif [400, 401, 403].include?(response.status.to_i) = 'Authorization failed.' if response.body.to_s.strip.length > 0 += " Server message:\n#{response.body.to_s.strip}" end raise ::Signet::AuthorizationError.new( , :request => request, :response => response ) else = "Unexpected status code: #{response.status}." if response.body.to_s.strip.length > 0 += " Server message:\n#{response.body.to_s.strip}" end raise ::Signet::AuthorizationError.new( , :request => request, :response => response ) end end |
#fetch_temporary_credential!(options = {}) ⇒ Signet::OAuth1::Credential Also known as: fetch_request_token!
Transmits a request for a temporary credential. This method updates the client with the new temporary credential.
654 655 656 657 |
# File 'lib/signet/oauth_1/client.rb', line 654 def fetch_temporary_credential!(={}) credential = self.fetch_temporary_credential() self.temporary_credential = credential end |
#fetch_token_credential(options = {}) ⇒ Signet::OAuth1::Credential Also known as: fetch_access_token
Transmits a request for a token credential. This method does not have side-effects within the client.
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
# File 'lib/signet/oauth_1/client.rb', line 753 def fetch_token_credential(={}) [:connection] ||= Faraday.default_connection request = self.generate_token_credential_request() request_env = request.to_env([:connection]) response = [:connection].app.call(request_env) if response.status.to_i == 200 return ::Signet::OAuth1.parse_form_encoded_credentials(response.body) elsif [400, 401, 403].include?(response.status.to_i) = 'Authorization failed.' if response.body.to_s.strip.length > 0 += " Server message:\n#{response.body.to_s.strip}" end raise ::Signet::AuthorizationError.new( , :request => request, :response => response ) else = "Unexpected status code: #{response.status}." if response.body.to_s.strip.length > 0 += " Server message:\n#{response.body.to_s.strip}" end raise ::Signet::AuthorizationError.new( , :request => request, :response => response ) end end |
#fetch_token_credential!(options = {}) ⇒ Signet::OAuth1::Credential Also known as: fetch_access_token!
Transmits a request for a token credential. This method updates the client with the new token credential.
803 804 805 806 |
# File 'lib/signet/oauth_1/client.rb', line 803 def fetch_token_credential!(={}) credential = self.fetch_token_credential() self.token_credential = credential end |
#generate_authenticated_request(options = {}) ⇒ Array
Generates an authenticated request for protected resources.
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/signet/oauth_1/client.rb', line 833 def generate_authenticated_request(={}) verifications = { :client_credential_key => 'Client credential key', :client_credential_secret => 'Client credential secret' } unless self.two_legged verifications.update( :token_credential_key => 'Token credential key', :token_credential_secret => 'Token credential secret' ) end # Make sure all required state is set verifications.each do |(key, value)| unless self.send(key) raise ArgumentError, "#{key} was not set." end end = { :signature_method => 'HMAC-SHA1', :realm => nil }.merge() if [:request] if [:request].kind_of?(Array) method, uri, headers, body = [:request] elsif [:request].kind_of?(Faraday::Request) unless [:connection] raise ArgumentError, "Faraday::Request used, requires a connection to be provided." end method = [:request].method.to_s.downcase.to_sym uri = [:connection].build_url( [:request].path, [:request].params ) headers = [:request].headers || {} body = [:request].body || '' end else method = [:method] || :get uri = [:uri] headers = [:headers] || [] body = [:body] || '' end headers = headers.to_a if headers.kind_of?(Hash) request_components = { :method => method, :uri => uri, :headers => headers, :body => body } # Verify that we have all pieces required to return an HTTP request request_components.each do |(key, value)| unless value raise ArgumentError, "Missing :#{key} parameter." end end if !body.kind_of?(String) && body.respond_to?(:each) # Just in case we get a chunked body merged_body = StringIO.new body.each do |chunk| merged_body.write(chunk) end body = merged_body.string end if !body.kind_of?(String) raise TypeError, "Expected String, got #{body.class}." end method = method.to_s.downcase.to_sym parameters = ::Signet::OAuth1.unsigned_resource_parameters( :client_credential_key => self.client_credential_key, :token_credential_key => self.token_credential_key, :signature_method => [:signature_method], :two_legged => self.two_legged ) media_type = nil headers.each do |(header, value)| if header.downcase == 'Content-Type'.downcase media_type = value.gsub(/^([^;]+)(;.*?)?$/, '\1') end end if method == :post && media_type == 'application/x-www-form-urlencoded' post_parameters = Addressable::URI.form_unencode(body) else post_parameters = [] end parameters = parameters.concat(post_parameters) # No need to attach URI query parameters, the .sign_parameters # method takes care of that automatically. signature = ::Signet::OAuth1.sign_parameters( method, uri, parameters, self.client_credential_secret, self.token_credential_secret ) parameters << ['oauth_signature', signature] = [ 'Authorization', ::Signet::OAuth1.( parameters, [:realm] ) ] headers << headers << ['Cache-Control', 'no-store'] return Faraday::Request.create(method.to_s.downcase.to_sym) do |req| req.url(Addressable::URI.parse(uri)) req.headers = Faraday::Utils::Headers.new(headers) req.body = body end end |
#generate_temporary_credential_request(options = {}) ⇒ Array Also known as: generate_request_token_request
Generates a request for temporary credentials.
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/signet/oauth_1/client.rb', line 526 def generate_temporary_credential_request(={}) verifications = { :temporary_credential_uri => 'Temporary credentials URI', :client_credential_key => 'Client credential key', :client_credential_secret => 'Client credential secret' } # Make sure all required state is set verifications.each do |(key, value)| unless self.send(key) raise ArgumentError, "#{key} was not set." end end = { :signature_method => 'HMAC-SHA1', :additional_parameters => [], :realm => nil }.merge() method = :post parameters = ::Signet::OAuth1.unsigned_temporary_credential_parameters( :client_credential_key => self.client_credential_key, :callback => self.callback, :signature_method => [:signature_method], :additional_parameters => [:additional_parameters] ) signature = ::Signet::OAuth1.sign_parameters( method, self.temporary_credential_uri, parameters, self.client_credential_secret ) parameters << ['oauth_signature', signature] = [ 'Authorization', ::Signet::OAuth1.( parameters, [:realm] ) ] headers = [] if method == :post headers << ['Content-Type', 'application/x-www-form-urlencoded'] headers << ['Content-Length', '0'] end return Faraday::Request.create(method.to_s.downcase.to_sym) do |req| req.url(Addressable::URI.parse(self.temporary_credential_uri.to_str)) req.headers = Faraday::Utils::Headers.new(headers) end end |
#generate_token_credential_request(options = {}) ⇒ Array Also known as: generate_access_token_request
Generates a request for token credentials.
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 |
# File 'lib/signet/oauth_1/client.rb', line 676 def generate_token_credential_request(={}) verifications = { :token_credential_uri => 'Token credentials URI', :client_credential_key => 'Client credential key', :client_credential_secret => 'Client credential secret', :temporary_credential_key => 'Temporary credential key', :temporary_credential_secret => 'Temporary credential secret' } # Make sure all required state is set verifications.each do |(key, value)| unless self.send(key) raise ArgumentError, "#{key} was not set." end end = { :signature_method => 'HMAC-SHA1', :realm => nil }.merge() method = :post parameters = ::Signet::OAuth1.unsigned_token_credential_parameters( :client_credential_key => self.client_credential_key, :temporary_credential_key => self.temporary_credential_key, :signature_method => [:signature_method], :verifier => [:verifier] ) signature = ::Signet::OAuth1.sign_parameters( method, self.token_credential_uri, parameters, self.client_credential_secret, self.temporary_credential_secret ) parameters << ['oauth_signature', signature] = [ 'Authorization', ::Signet::OAuth1.( parameters, [:realm] ) ] headers = [] headers << ['Cache-Control', 'no-store'] if method == :post headers << ['Content-Type', 'application/x-www-form-urlencoded'] headers << ['Content-Length', '0'] end return Faraday::Request.create(method.to_s.downcase.to_sym) do |req| req.url(Addressable::URI.parse(self.token_credential_uri.to_str)) req.headers = Faraday::Utils::Headers.new(headers) end end |
#temporary_credential ⇒ Signet::OAuth1::Credential Also known as: request_token
Returns the temporary credential for this client.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/signet/oauth_1/client.rb', line 268 def temporary_credential if self.temporary_credential_key && self.temporary_credential_secret return ::Signet::OAuth1::Credential.new( self.temporary_credential_key, self.temporary_credential_secret ) elsif !self.temporary_credential_key && !self.temporary_credential_secret return nil else raise ArgumentError, "The temporary credential key and secret must be set." end end |
#temporary_credential=(new_temporary_credential) ⇒ Object Also known as: request_token=
Sets the temporary credential for this client.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/signet/oauth_1/client.rb', line 289 def temporary_credential=(new_temporary_credential) if new_temporary_credential != nil if !new_temporary_credential.kind_of?(::Signet::OAuth1::Credential) raise TypeError, "Expected Signet::OAuth1::Credential, " + "got #{new_temporary_credential.class}." end @temporary_credential_key = new_temporary_credential.key @temporary_credential_secret = new_temporary_credential.secret else @temporary_credential_key = nil @temporary_credential_secret = nil end end |
#temporary_credential_key ⇒ String Also known as: request_token_key
Returns the temporary credential key for this client.
309 310 311 |
# File 'lib/signet/oauth_1/client.rb', line 309 def temporary_credential_key return @temporary_credential_key end |
#temporary_credential_key=(new_temporary_credential_key) ⇒ Object Also known as: request_token_key=
Sets the temporary credential key for this client.
319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/signet/oauth_1/client.rb', line 319 def temporary_credential_key=(new_temporary_credential_key) if new_temporary_credential_key != nil if !new_temporary_credential_key.respond_to?(:to_str) raise TypeError, "Can't convert #{new_temporary_credential_key.class} " + "into String." end new_temporary_credential_key = new_temporary_credential_key.to_str @temporary_credential_key = new_temporary_credential_key else @temporary_credential_key = nil end end |
#temporary_credential_secret ⇒ String Also known as: request_token_secret
Returns the temporary credential secret for this client.
338 339 340 |
# File 'lib/signet/oauth_1/client.rb', line 338 def temporary_credential_secret return @temporary_credential_secret end |
#temporary_credential_secret=(new_temporary_credential_secret) ⇒ Object Also known as: request_token_secret=
Sets the temporary credential secret for this client.
348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/signet/oauth_1/client.rb', line 348 def temporary_credential_secret=(new_temporary_credential_secret) if new_temporary_credential_secret != nil if !new_temporary_credential_secret.respond_to?(:to_str) raise TypeError, "Can't convert #{new_temporary_credential_secret.class} " + "into String." end new_temporary_credential_secret = new_temporary_credential_secret.to_str @temporary_credential_secret = new_temporary_credential_secret else @temporary_credential_secret = nil end end |
#temporary_credential_uri ⇒ Addressable::URI Also known as: request_token_uri
Returns the temporary credentials URI for this client.
83 84 85 |
# File 'lib/signet/oauth_1/client.rb', line 83 def temporary_credential_uri return @temporary_credential_uri end |
#temporary_credential_uri=(new_temporary_credential_uri) ⇒ Object Also known as: request_token_uri=
Sets the temporary credentials URI for this client.
94 95 96 97 98 99 100 101 102 |
# File 'lib/signet/oauth_1/client.rb', line 94 def temporary_credential_uri=(new_temporary_credential_uri) if new_temporary_credential_uri != nil new_temporary_credential_uri = Addressable::URI.parse(new_temporary_credential_uri) @temporary_credential_uri = new_temporary_credential_uri else @temporary_credential_uri = nil end end |
#token_credential ⇒ Signet::OAuth1::Credential Also known as: access_token
Returns the token credential for this client.
368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/signet/oauth_1/client.rb', line 368 def token_credential if self.token_credential_key && self.token_credential_secret return ::Signet::OAuth1::Credential.new( self.token_credential_key, self.token_credential_secret ) elsif !self.token_credential_key && !self.token_credential_secret return nil else raise ArgumentError, "The token credential key and secret must be set." end end |
#token_credential=(new_token_credential) ⇒ Object Also known as: access_token=
Sets the token credential for this client.
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/signet/oauth_1/client.rb', line 389 def token_credential=(new_token_credential) if new_token_credential != nil if !new_token_credential.kind_of?(::Signet::OAuth1::Credential) raise TypeError, "Expected Signet::OAuth1::Credential, " + "got #{new_token_credential.class}." end @token_credential_key = new_token_credential.key @token_credential_secret = new_token_credential.secret else @token_credential_key = nil @token_credential_secret = nil end end |
#token_credential_key ⇒ String Also known as: access_token_key
Returns the token credential key for this client.
409 410 411 |
# File 'lib/signet/oauth_1/client.rb', line 409 def token_credential_key return @token_credential_key end |
#token_credential_key=(new_token_credential_key) ⇒ Object Also known as: access_token_key=
Sets the token credential key for this client.
419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/signet/oauth_1/client.rb', line 419 def token_credential_key=(new_token_credential_key) if new_token_credential_key != nil if !new_token_credential_key.respond_to?(:to_str) raise TypeError, "Can't convert #{new_token_credential_key.class} " + "into String." end new_token_credential_key = new_token_credential_key.to_str @token_credential_key = new_token_credential_key else @token_credential_key = nil end end |
#token_credential_secret ⇒ String Also known as: access_token_secret
Returns the token credential secret for this client.
438 439 440 |
# File 'lib/signet/oauth_1/client.rb', line 438 def token_credential_secret return @token_credential_secret end |
#token_credential_secret=(new_token_credential_secret) ⇒ Object Also known as: access_token_secret=
Sets the token credential secret for this client.
448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/signet/oauth_1/client.rb', line 448 def token_credential_secret=(new_token_credential_secret) if new_token_credential_secret != nil if !new_token_credential_secret.respond_to?(:to_str) raise TypeError, "Can't convert #{new_token_credential_secret.class} " + "into String." end new_token_credential_secret = new_token_credential_secret.to_str @token_credential_secret = new_token_credential_secret else @token_credential_secret = nil end end |
#token_credential_uri ⇒ Addressable::URI Also known as: access_token_uri
Returns the token credential URI for this client.
143 144 145 |
# File 'lib/signet/oauth_1/client.rb', line 143 def token_credential_uri return @token_credential_uri end |
#token_credential_uri=(new_token_credential_uri) ⇒ Object Also known as: access_token_uri=
Sets the token credential URI for this client.
153 154 155 156 157 158 159 160 161 |
# File 'lib/signet/oauth_1/client.rb', line 153 def token_credential_uri=(new_token_credential_uri) if new_token_credential_uri != nil new_token_credential_uri = Addressable::URI.parse(new_token_credential_uri) @token_credential_uri = new_token_credential_uri else @token_credential_uri = nil end end |
#two_legged ⇒ TrueClass, FalseClass
Returns whether the client is in two-legged mode.
495 496 497 |
# File 'lib/signet/oauth_1/client.rb', line 495 def two_legged return @two_legged ||= false end |
#two_legged=(new_two_legged) ⇒ Object
Sets the client for two-legged mode.
504 505 506 507 508 509 510 511 |
# File 'lib/signet/oauth_1/client.rb', line 504 def two_legged=(new_two_legged) if new_two_legged != true && new_two_legged != false raise TypeError, "Expected true or false, got #{new_two_legged.class}." else @two_legged = new_two_legged end end |