Reference documentation and code samples for the signet module Signet::OAuth1.
:nodoc:
Methods
.encode
def self.encode(value) -> String
Converts a value to a percent-encoded String
according to
the rules given in RFC 5849. All non-unreserved characters are
percent-encoded.
- value (Symbol, #to_str) — The value to be encoded.
- (String) — The percent-encoded value.
.extract_credential_key_option
def self.extract_credential_key_option(credential_type, options) -> String
Processes an options Hash
to find a credential key value.
Allows for greater flexibility in configuration.
-
credential_type (Symbol) — One of
:client
,:temporary
,:token
,:consumer
,:request
, or:access
.
- (String) — The credential key value.
.extract_credential_secret_option
def self.extract_credential_secret_option(credential_type, options) -> String
Processes an options Hash
to find a credential secret value.
Allows for greater flexibility in configuration.
-
credential_type (Symbol) — One of
:client
,:temporary
,:token
,:consumer
,:request
, or:access
.
- (String) — The credential secret value.
.generate_authorization_header
def self.generate_authorization_header(parameters, realm = nil) -> String
Generates an Authorization
header from a parameter list
according to the rules given in RFC 5849.
- parameters (Enumerable) — The OAuth parameter list.
-
realm (String) — The
Authorization
realm. See RFC 2617.
-
(String) — The
Authorization
header.
.generate_authorization_uri
def self.generate_authorization_uri(authorization_uri, options = {}) -> String
Appends the optional 'oauth_token' and 'oauth_callback' parameters to the base authorization URI.
- authorization_uri (Addressable::URI, String, #to_str) — The base authorization URI.
- (String) — The authorization URI to redirect the user to.
.generate_base_string
def self.generate_base_string(method, uri, parameters) -> String
Generates a signature base string according to the algorithm given in RFC 5849. Joins the method, URI, and normalized parameter string with '&' characters.
- method (String) — The HTTP method.
- uri (Addressable::URI, String, #to_str) — The URI.
- parameters (Enumerable) — The OAuth parameter list.
- (String) — The signature base string.
- (TypeError)
.generate_nonce
def self.generate_nonce() -> String
Returns a nonce suitable for use as an 'oauth_nonce'
value.
- (String) — A random nonce.
.generate_timestamp
def self.generate_timestamp() -> String
Returns a timestamp suitable for use as an 'oauth_timestamp'
value.
- (String) — The current timestamp.
.normalize_parameters
def self.normalize_parameters(parameters) -> String
Normalizes a set of OAuth parameters according to the algorithm given in RFC 5849. Sorts key/value pairs lexically by byte order, first by key, then by value, joins key/value pairs with the '=' character, then joins the entire parameter list with '&' characters.
- parameters (Enumerable) — The OAuth parameter list.
- (String) — The normalized parameter list.
- (TypeError)
.parse_authorization_header
def self.parse_authorization_header(field_value)
Parses an Authorization
header into its component
parameters. Parameter keys and values are decoded according to the
rules given in RFC 5849.
- (TypeError)
.parse_form_encoded_credentials
def self.parse_form_encoded_credentials(body) -> Signet::OAuth1::Credential
Parses an application/x-www-form-urlencoded
HTTP response
body into an OAuth key/secret pair.
- body (String) — The response body.
- (Signet::OAuth1::Credential) — The OAuth credentials.
- (TypeError)
.sign_parameters
def self.sign_parameters(method, uri, parameters, client_credential_secret, token_credential_secret = nil) -> String
Generates an OAuth signature using the signature method indicated in the
parameter list. Unsupported signature methods will result in a
NotImplementedError
exception being raised.
- method (String) — The HTTP method.
- uri (Addressable::URI, String, #to_str) — The URI.
- parameters (Enumerable) — The OAuth parameter list.
- client_credential_secret (String) — The client credential secret.
- token_credential_secret (String) — The token credential secret. Omitted when unavailable.
- (String) — The signature.
.unencode
def self.unencode(value) -> String
Converts a percent-encoded String to an unencoded value.
-
value (#to_str) — The percent-encoded
String
to be unencoded.
- (String) — The unencoded value.
.unsigned_resource_parameters
def self.unsigned_resource_parameters(options = {}) -> Array
Generates an OAuth parameter list to be used when requesting a protected resource.
-
options (Hash) —
The configuration parameters for the request.
:client_credential_key
- The client credential key.:token_credential_key
- The token credential key.:signature_method
- The signature method. Defaults to'HMAC-SHA1'
.:two_legged
- A switch for two-legged OAuth. Defaults tofalse
.
-
(Array) — The parameter list as an
Array
of key/value pairs.
- (ArgumentError)
.unsigned_temporary_credential_parameters
def self.unsigned_temporary_credential_parameters(options = {}) -> Array
Generates an OAuth parameter list to be used when obtaining a set of temporary credentials.
-
options (Hash) —
The configuration parameters for the request.
:client_credential_key
- The client credential key.:callback
- The OAuth callback. Defaults to OUT_OF_BAND.:signature_method
- The signature method. Defaults to'HMAC-SHA1'
.:additional_parameters
- Non-standard additional parameters.
-
(Array) — The parameter list as an
Array
of key/value pairs.
- (ArgumentError)
.unsigned_token_credential_parameters
def self.unsigned_token_credential_parameters(options = {}) -> Array
Generates an OAuth parameter list to be used when obtaining a set of token credentials.
-
options (Hash) —
The configuration parameters for the request.
:client_credential_key
- The client credential key.:temporary_credential_key
- The temporary credential key.:verifier
- The OAuth verifier.:signature_method
- The signature method. Defaults to'HMAC-SHA1'
.
-
(Array) — The parameter list as an
Array
of key/value pairs.
- (ArgumentError)
Constants
OUT_OF_BAND
value: "oob".freeze