signet - Class Signet::OAuth1::Client (v0.20.0)

Reference documentation and code samples for the signet class Signet::OAuth1::Client.

Inherits

  • Object

Methods

#access_token

  def 
  
 access_token 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 
Alias Of: #token_credential

Returns the token credential for this client.

Returns

#access_token=

  def 
  
 access_token= 
 ( 
 new_token_credential 
 ) 
 
Alias Of: #token_credential=

Sets the token credential for this client.

Parameter

#access_token_key

  def 
  
 access_token_key 
 () 
  
 - 
>  
 String 
 

Returns the token credential key for this client.

Returns
  • (String) — The token credential key.

#access_token_key=

  def 
  
 access_token_key= 
 ( 
 new_token_credential_key 
 ) 
 

Sets the token credential key for this client.

Parameter
  • new_token_credential_key(String, #to_str) — The token credential key.

#access_token_secret

  def 
  
 access_token_secret 
 () 
  
 - 
>  
 String 
 

Returns the token credential secret for this client.

Returns
  • (String) — The token credential secret.

#access_token_secret=

  def 
  
 access_token_secret= 
 ( 
 new_token_credential_secret 
 ) 
 

Sets the token credential secret for this client.

Parameter
  • new_token_credential_secret(String, #to_str) — The token credential secret.

#access_token_uri

  def 
  
 access_token_uri 
 () 
  
 - 
>  
 Addressable 
 :: 
 URI 
 

Returns the token credential URI for this client.

Returns
  • (Addressable::URI) — The token credential URI.

#access_token_uri=

  def 
  
 access_token_uri= 
 ( 
 new_token_credential_uri 
 ) 
 

Sets the token credential URI for this client.

Parameter
  • new_token_credential_uri(Addressable::URI, Hash, String, #to_str) — The token credential URI.

#authorization_uri

  def 
  
 authorization_uri 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Addressable 
 :: 
 URI 
 

Returns the authorization URI that the user should be redirected to.

Returns
  • (Addressable::URI) — The authorization URI.

#authorization_uri=

  def 
  
 authorization_uri= 
 ( 
 new_authorization_uri 
 ) 
 

Sets the authorization URI for this client.

Parameter
  • new_authorization_uri(Addressable::URI, String, #to_str) — The authorization URI.

#callback

  def 
  
 callback 
 () 
  
 - 
>  
 String 
 

Returns the callback for this client.

Returns
  • (String) — The OAuth callback.

#callback=

  def 
  
 callback= 
 ( 
 new_callback 
 ) 
 

Sets the callback for this client.

Parameter
  • new_callback(String, #to_str) — The OAuth callback.

#client_credential

  def 
  
 client_credential 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 
Aliases

Returns the client credential for this client.

Returns

#client_credential=

  def 
  
 client_credential= 
 ( 
 new_client_credential 
 ) 
 

Sets the client credential for this client.

Parameter

#client_credential_key

  def 
  
 client_credential_key 
 () 
  
 - 
>  
 String 
 
Aliases

Returns the client credential key for this client.

Returns
  • (String) — The client credential key.

#client_credential_key=

  def 
  
 client_credential_key= 
 ( 
 new_client_credential_key 
 ) 
 
Aliases

Sets the client credential key for this client.

Parameter
  • new_client_credential_key(String, #to_str) — The client credential key.

#client_credential_secret

  def 
  
 client_credential_secret 
 () 
  
 - 
>  
 String 
 

Returns the client credential secret for this client.

Returns
  • (String) — The client credential secret.

#client_credential_secret=

  def 
  
 client_credential_secret= 
 ( 
 new_client_credential_secret 
 ) 
 

Sets the client credential secret for this client.

Parameter
  • new_client_credential_secret(String, #to_str) — The client credential secret.

#consumer_key

  def 
  
 consumer_key 
 () 
  
 - 
>  
 String 
 

Returns the client credential key for this client.

Returns
  • (String) — The client credential key.

#consumer_key=

  def 
  
 consumer_key= 
 ( 
 new_client_credential_key 
 ) 
 

Sets the client credential key for this client.

Parameter
  • new_client_credential_key(String, #to_str) — The client credential key.

#consumer_secret

  def 
  
 consumer_secret 
 () 
  
 - 
>  
 String 
 

Returns the client credential secret for this client.

Returns
  • (String) — The client credential secret.

#consumer_secret=

  def 
  
 consumer_secret= 
 ( 
 new_client_credential_secret 
 ) 
 

Sets the client credential secret for this client.

Parameter
  • new_client_credential_secret(String, #to_str) — The client credential secret.

#consumer_token

  def 
  
 consumer_token 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 
Alias Of: #client_credential

Returns the client credential for this client.

Returns

#consumer_token=

  def 
  
 consumer_token= 
 ( 
 new_client_credential 
 ) 
 

Sets the client credential for this client.

Parameter

#fetch_access_token

  def 
  
 fetch_access_token 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a token credential. This method does not have side-effects within the client.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :verifier - The OAuth verifier provided by the server. Required.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 token_credential 
  
 = 
  
 client 
 . 
 fetch_token_credential 
 ( 
  
 :verifier 
  
 = 
>  
 '12345' 
 ) 

#fetch_access_token!

  def 
  
 fetch_access_token! 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a token credential. This method updates the client with the new token credential.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 client 
 . 
 fetch_token_credential! 
 ( 
 :verifier 
  
 = 
>  
 '12345' 
 ) 

#fetch_protected_resource

  def 
  
 fetch_protected_resource 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Transmits a request for a protected resource.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :request - A pre-constructed request to sign.
    • :method - The HTTP method for the request. Defaults to :get.
    • :uri - The URI for the request.
    • :headers - The HTTP headers for the request.
    • :body - The HTTP body for the request.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
  • (Array) — The response object.
Examples
 # Using Net::HTTP 
 response 
  
 = 
  
 client 
 . 
 fetch_protected_resource 
 ( 
  
 :uri 
  
 = 
>  
 'http://www.example.com/protected/resource' 
 ) 
 # Using Typhoeus 
 response 
  
 = 
  
 client 
 . 
 fetch_protected_resource 
 ( 
  
 :request 
  
 = 
>  
 Typhoeus 
 :: 
 Request 
 . 
 new 
 ( 
  
 'http://www.example.com/protected/resource' 
  
 ), 
  
 :connection 
  
 = 
>  
 connection 
 ) 

#fetch_request_token

  def 
  
 fetch_request_token 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a temporary credential. This method does not have side-effects within the client.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 temporary_credential 
  
 = 
  
 client 
 . 
 fetch_temporary_credential 
 ( 
  
 :additional_parameters 
  
 = 
>  
 { 
  
 :scope 
  
 = 
>  
 'https://mail.google.com/mail/feed/atom' 
  
 } 
 ) 

#fetch_request_token!

  def 
  
 fetch_request_token! 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a temporary credential. This method updates the client with the new temporary credential.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 client 
 . 
 fetch_temporary_credential! 
 ( 
 :additional_parameters 
  
 = 
>  
 { 
  
 :scope 
  
 = 
>  
 'https://mail.google.com/mail/feed/atom' 
 }) 

#fetch_temporary_credential

  def 
  
 fetch_temporary_credential 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a temporary credential. This method does not have side-effects within the client.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 temporary_credential 
  
 = 
  
 client 
 . 
 fetch_temporary_credential 
 ( 
  
 :additional_parameters 
  
 = 
>  
 { 
  
 :scope 
  
 = 
>  
 'https://mail.google.com/mail/feed/atom' 
  
 } 
 ) 

#fetch_temporary_credential!

  def 
  
 fetch_temporary_credential! 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a temporary credential. This method updates the client with the new temporary credential.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 client 
 . 
 fetch_temporary_credential! 
 ( 
 :additional_parameters 
  
 = 
>  
 { 
  
 :scope 
  
 = 
>  
 'https://mail.google.com/mail/feed/atom' 
 }) 

#fetch_token_credential

  def 
  
 fetch_token_credential 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a token credential. This method does not have side-effects within the client.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :verifier - The OAuth verifier provided by the server. Required.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 token_credential 
  
 = 
  
 client 
 . 
 fetch_token_credential 
 ( 
  
 :verifier 
  
 = 
>  
 '12345' 
 ) 

#fetch_token_credential!

  def 
  
 fetch_token_credential! 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Transmits a request for a token credential. This method updates the client with the new token credential.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
    • :connection - The HTTP connection to use. Must be of type Faraday::Connection .
Returns
Example
 client 
 . 
 fetch_token_credential! 
 ( 
 :verifier 
  
 = 
>  
 '12345' 
 ) 

#generate_access_token_request

  def 
  
 generate_access_token_request 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Generates a request for token credentials.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :verifier - The OAuth verifier provided by the server. Required.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
Returns
  • (Array) — The request object.

#generate_authenticated_request

  def 
  
 generate_authenticated_request 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Generates an authenticated request for protected resources.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :request - A pre-constructed request to sign.
    • :method - The HTTP method for the request. Defaults to :get.
    • :uri - The URI for the request.
    • :headers - The HTTP headers for the request.
    • :body - The HTTP body for the request.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
Returns
  • (Array) — The request object.

#generate_request_token_request

  def 
  
 generate_request_token_request 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Generates a request for temporary credentials.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
Returns
  • (Array) — The request object.

#generate_temporary_credential_request

  def 
  
 generate_temporary_credential_request 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Generates a request for temporary credentials.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :additional_parameters - Non-standard additional parameters.
    • :realm - The Authorization realm. See RFC 2617.
Returns
  • (Array) — The request object.

#generate_token_credential_request

  def 
  
 generate_token_credential_request 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Array 
 

Generates a request for token credentials.

Parameter
  • options(Hash) —

    The configuration parameters for the request.

    • :verifier - The OAuth verifier provided by the server. Required.
    • :signature_method - The signature method. Defaults to 'HMAC-SHA1' .
    • :realm - The Authorization realm. See RFC 2617.
Returns
  • (Array) — The request object.

#initialize

  def 
  
 initialize 
 ( 
 options 
  
 = 
  
 {}) 
  
 - 
>  
 Client 
 

Creates an OAuth 1.0 client.

Parameter
  • options(Hash) —

    The configuration parameters for the client.

    • :temporary_credential_uri - The OAuth temporary credentials URI.
    • :authorization_uri - The OAuth authorization URI.
    • :token_credential_uri - The OAuth token credentials URI.
    • :client_credential_key - The OAuth client credential key.
    • :client_credential_secret - The OAuth client credential secret.
    • :callback - The OAuth callback. Defaults to 'oob'.
Returns
  • ( Client ) — a new instance of Client
Example
 client 
  
 = 
  
 Signet 
 :: 
 OAuth1 
 :: 
 Client 
 . 
 new 
 ( 
  
 :temporary_credential_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthGetRequestToken' 
 , 
  
 :authorization_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthAuthorizeToken' 
 , 
  
 :token_credential_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthGetAccessToken' 
 , 
  
 :client_credential_key 
  
 = 
>  
 'anonymous' 
 , 
  
 :client_credential_secret 
  
 = 
>  
 'anonymous' 
 ) 

#request_token

  def 
  
 request_token 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 

Returns the temporary credential for this client.

Returns

#request_token=

  def 
  
 request_token= 
 ( 
 new_temporary_credential 
 ) 
 

Sets the temporary credential for this client.

Parameter

#request_token_key

  def 
  
 request_token_key 
 () 
  
 - 
>  
 String 
 

Returns the temporary credential key for this client.

Returns
  • (String) — The temporary credential key.

#request_token_key=

  def 
  
 request_token_key= 
 ( 
 new_temporary_credential_key 
 ) 
 

Sets the temporary credential key for this client.

Parameter
  • new_temporary_credential_key(String, #to_str) — The temporary credential key.

#request_token_secret

  def 
  
 request_token_secret 
 () 
  
 - 
>  
 String 
 

Returns the temporary credential secret for this client.

Returns
  • (String) — The temporary credential secret.

#request_token_secret=

  def 
  
 request_token_secret= 
 ( 
 new_temporary_credential_secret 
 ) 
 

Sets the temporary credential secret for this client.

Parameter
  • new_temporary_credential_secret(String, #to_str) — The temporary credential secret.

#request_token_uri

  def 
  
 request_token_uri 
 () 
  
 - 
>  
 Addressable 
 :: 
 URI 
 

Returns the temporary credentials URI for this client.

Returns
  • (Addressable::URI) — The temporary credentials URI.

#request_token_uri=

  def 
  
 request_token_uri= 
 ( 
 new_temporary_credential_uri 
 ) 
 

Sets the temporary credentials URI for this client.

Parameter
  • new_temporary_credential_uri(Addressable::URI, String, #to_str) — The temporary credentials URI.

#temporary_credential

  def 
  
 temporary_credential 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 
Aliases

Returns the temporary credential for this client.

Returns

#temporary_credential=

  def 
  
 temporary_credential= 
 ( 
 new_temporary_credential 
 ) 
 
Aliases

Sets the temporary credential for this client.

Parameter

#temporary_credential_key

  def 
  
 temporary_credential_key 
 () 
  
 - 
>  
 String 
 

Returns the temporary credential key for this client.

Returns
  • (String) — The temporary credential key.

#temporary_credential_key=

  def 
  
 temporary_credential_key= 
 ( 
 new_temporary_credential_key 
 ) 
 

Sets the temporary credential key for this client.

Parameter
  • new_temporary_credential_key(String, #to_str) — The temporary credential key.

#temporary_credential_secret

  def 
  
 temporary_credential_secret 
 () 
  
 - 
>  
 String 
 

Returns the temporary credential secret for this client.

Returns
  • (String) — The temporary credential secret.

#temporary_credential_secret=

  def 
  
 temporary_credential_secret= 
 ( 
 new_temporary_credential_secret 
 ) 
 

Sets the temporary credential secret for this client.

Parameter
  • new_temporary_credential_secret(String, #to_str) — The temporary credential secret.

#temporary_credential_uri

  def 
  
 temporary_credential_uri 
 () 
  
 - 
>  
 Addressable 
 :: 
 URI 
 

Returns the temporary credentials URI for this client.

Returns
  • (Addressable::URI) — The temporary credentials URI.

#temporary_credential_uri=

  def 
  
 temporary_credential_uri= 
 ( 
 new_temporary_credential_uri 
 ) 
 

Sets the temporary credentials URI for this client.

Parameter
  • new_temporary_credential_uri(Addressable::URI, String, #to_str) — The temporary credentials URI.

#to_json

  def 
  
 to_json 
 ( 
 * 
 _args 
 ) 
  
 - 
>  
 String 
 

Serialize the client object to JSON.

Returns
  • (String) — A serialized JSON representation of the client.

#token_credential

  def 
  
 token_credential 
 () 
  
 - 
>  
 Signet 
 :: 
 OAuth1 
 :: 
 Credential 
 
Aliases

Returns the token credential for this client.

Returns

#token_credential=

  def 
  
 token_credential= 
 ( 
 new_token_credential 
 ) 
 
Aliases

Sets the token credential for this client.

Parameter

#token_credential_key

  def 
  
 token_credential_key 
 () 
  
 - 
>  
 String 
 

Returns the token credential key for this client.

Returns
  • (String) — The token credential key.

#token_credential_key=

  def 
  
 token_credential_key= 
 ( 
 new_token_credential_key 
 ) 
 

Sets the token credential key for this client.

Parameter
  • new_token_credential_key(String, #to_str) — The token credential key.

#token_credential_secret

  def 
  
 token_credential_secret 
 () 
  
 - 
>  
 String 
 

Returns the token credential secret for this client.

Returns
  • (String) — The token credential secret.

#token_credential_secret=

  def 
  
 token_credential_secret= 
 ( 
 new_token_credential_secret 
 ) 
 

Sets the token credential secret for this client.

Parameter
  • new_token_credential_secret(String, #to_str) — The token credential secret.

#token_credential_uri

  def 
  
 token_credential_uri 
 () 
  
 - 
>  
 Addressable 
 :: 
 URI 
 

Returns the token credential URI for this client.

Returns
  • (Addressable::URI) — The token credential URI.

#token_credential_uri=

  def 
  
 token_credential_uri= 
 ( 
 new_token_credential_uri 
 ) 
 

Sets the token credential URI for this client.

Parameter
  • new_token_credential_uri(Addressable::URI, Hash, String, #to_str) — The token credential URI.

#two_legged

  def 
  
 two_legged 
 () 
  
 - 
>  
 TrueClass 
 , 
  
 FalseClass 
 

Returns whether the client is in two-legged mode.

Returns
  • (TrueClass, FalseClass) — true for two-legged mode, false otherwise.

#two_legged=

  def 
  
 two_legged= 
 ( 
 new_two_legged 
 ) 
 

Sets the client for two-legged mode.

Parameter
  • new_two_legged(TrueClass, FalseClass) — true for two-legged mode, false otherwise.

#update!

  def 
  
 update! 
 ( 
 options 
  
 = 
  
 {}) 
 

Updates an OAuth 1.0 client.

Parameter
  • options(Hash) —

    The configuration parameters for the client.

    • :temporary_credential_uri - The OAuth temporary credentials URI.
    • :authorization_uri - The OAuth authorization URI.
    • :token_credential_uri - The OAuth token credentials URI.
    • :client_credential_key - The OAuth client credential key.
    • :client_credential_secret - The OAuth client credential secret.
    • :callback - The OAuth callback. Defaults to 'oob'.
Example
 client 
 . 
 update! 
 ( 
  
 :temporary_credential_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthGetRequestToken' 
 , 
  
 :authorization_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthAuthorizeToken' 
 , 
  
 :token_credential_uri 
  
 = 
>  
 'https://www.google.com/accounts/OAuthGetAccessToken' 
 , 
  
 :client_credential_key 
  
 = 
>  
 'anonymous' 
 , 
  
 :client_credential_secret 
  
 = 
>  
 'anonymous' 
 ) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: