Generates a signature base string according to the algorithm given in
RFC 5849. Joins the method, URI, and normalized parameter string with
'&' characters.
Parameters
method(String) — The HTTP method.
uri(Addressable::URI, String, #to_str) — The URI.
parameters(Enumerable) — The OAuth parameter list.
Returns
(String) — The signature base string.
Raises
(TypeError)
.generate_nonce
defself.generate_nonce()->String
Returns a nonce suitable for use as an'oauth_nonce'value.
Returns
(String) — A random nonce.
.generate_timestamp
defself.generate_timestamp()->String
Returns a timestamp suitable for use as an'oauth_timestamp'value.
Returns
(String) — The current timestamp.
.normalize_parameters
defself.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.
Parameter
parameters(Enumerable) — The OAuth parameter list.
Returns
(String) — The normalized parameter list.
Raises
(TypeError)
.parse_authorization_header
defself.parse_authorization_header(field_value)
Parses anAuthorizationheader into its component
parameters. Parameter keys and values are decoded according to the
rules given in RFC 5849.
Generates an OAuth signature using the signature method indicated in the
parameter list. Unsupported signature methods will result in aNotImplementedErrorexception being raised.
Parameters
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.
Returns
(String) — The signature.
.unencode
defself.unencode(value)->String
Converts a percent-encoded String to an unencoded value.
Parameter
value(#to_str) — The percent-encodedStringto be unencoded.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# signet - Module Signet::OAuth1 (v0.21.0)\n\nVersion latestkeyboard_arrow_down\n\n- [0.21.0 (latest)](/ruby/docs/reference/signet/latest/Signet-OAuth1)\n- [0.20.0](/ruby/docs/reference/signet/0.20.0/Signet-OAuth1) \nReference documentation and code samples for the signet module Signet::OAuth1.\n\n:nodoc:\n\nMethods\n-------\n\n### .encode\n\n def self.encode(value) -\u003e String\n\nConverts a value to a percent-encoded `String` according to\nthe rules given in RFC 5849. All non-unreserved characters are\npercent-encoded. \n**Parameter**\n\n- **value** (Symbol, #to_str) --- The value to be encoded. \n**Returns**\n\n- (String) --- The percent-encoded value.\n\n### .extract_credential_key_option\n\n def self.extract_credential_key_option(credential_type, options) -\u003e String\n\nProcesses an options `Hash` to find a credential key value.\nAllows for greater flexibility in configuration. \n**Parameter**\n\n- **credential_type** (Symbol) --- One of `:client`, `:temporary`, `:token`, `:consumer`, `:request`, or `:access`. \n**Returns**\n\n- (String) --- The credential key value.\n\n### .extract_credential_secret_option\n\n def self.extract_credential_secret_option(credential_type, options) -\u003e String\n\nProcesses an options `Hash` to find a credential secret value.\nAllows for greater flexibility in configuration. \n**Parameter**\n\n- **credential_type** (Symbol) --- One of `:client`, `:temporary`, `:token`, `:consumer`, `:request`, or `:access`. \n**Returns**\n\n- (String) --- The credential secret value.\n\n### .generate_authorization_header\n\n def self.generate_authorization_header(parameters, realm = nil) -\u003e String\n\nGenerates an `Authorization` header from a parameter list\naccording to the rules given in RFC 5849. \n**Parameters**\n\n- **parameters** (Enumerable) --- The OAuth parameter list.\n- **realm** (String) --- The `Authorization` realm. See RFC 2617. \n**Returns**\n\n- (String) --- The `Authorization` header.\n\n### .generate_authorization_uri\n\n def self.generate_authorization_uri(authorization_uri, options = {}) -\u003e String\n\nAppends the optional 'oauth_token' and 'oauth_callback' parameters to\nthe base authorization URI. \n**Parameter**\n\n- **authorization_uri** (Addressable::URI, String, #to_str) --- The base authorization URI. \n**Returns**\n\n- (String) --- The authorization URI to redirect the user to.\n\n### .generate_base_string\n\n def self.generate_base_string(method, uri, parameters) -\u003e String\n\nGenerates a signature base string according to the algorithm given in\nRFC 5849. Joins the method, URI, and normalized parameter string with\n'\\&' characters. \n**Parameters**\n\n- **method** (String) --- The HTTP method.\n- **uri** (Addressable::URI, String, #to_str) --- The URI.\n- **parameters** (Enumerable) --- The OAuth parameter list. \n**Returns**\n\n- (String) --- The signature base string. \n**Raises**\n\n- (TypeError)\n\n### .generate_nonce\n\n def self.generate_nonce() -\u003e String\n\nReturns a nonce suitable for use as an `'oauth_nonce'`\nvalue. \n**Returns**\n\n- (String) --- A random nonce.\n\n### .generate_timestamp\n\n def self.generate_timestamp() -\u003e String\n\nReturns a timestamp suitable for use as an `'oauth_timestamp'`\nvalue. \n**Returns**\n\n- (String) --- The current timestamp.\n\n### .normalize_parameters\n\n def self.normalize_parameters(parameters) -\u003e String\n\nNormalizes a set of OAuth parameters according to the algorithm given\nin RFC 5849. Sorts key/value pairs lexically by byte order, first by\nkey, then by value, joins key/value pairs with the '=' character, then\njoins the entire parameter list with '\\&' characters. \n**Parameter**\n\n- **parameters** (Enumerable) --- The OAuth parameter list. \n**Returns**\n\n- (String) --- The normalized parameter list. \n**Raises**\n\n- (TypeError)\n\n### .parse_authorization_header\n\n def self.parse_authorization_header(field_value)\n\nParses an `Authorization` header into its component\nparameters. Parameter keys and values are decoded according to the\nrules given in RFC 5849. \n**Raises**\n\n- (TypeError)\n\n### .parse_form_encoded_credentials\n\n def self.parse_form_encoded_credentials(body) -\u003e Signet::OAuth1::Credential\n\nParses an `application/x-www-form-urlencoded` HTTP response\nbody into an OAuth key/secret pair. \n**Parameter**\n\n- **body** (String) --- The response body. \n**Returns**\n\n- ([Signet::OAuth1::Credential](./Signet-OAuth1-Credential)) --- The OAuth credentials. \n**Raises**\n\n- (TypeError)\n\n### .sign_parameters\n\n def self.sign_parameters(method, uri, parameters, client_credential_secret, token_credential_secret = nil) -\u003e String\n\nGenerates an OAuth signature using the signature method indicated in the\nparameter list. Unsupported signature methods will result in a\n`NotImplementedError` exception being raised. \n**Parameters**\n\n- **method** (String) --- The HTTP method.\n- **uri** (Addressable::URI, String, #to_str) --- The URI.\n- **parameters** (Enumerable) --- The OAuth parameter list.\n- **client_credential_secret** (String) --- The client credential secret.\n- **token_credential_secret** (String) --- The token credential secret. Omitted when unavailable. \n**Returns**\n\n- (String) --- The signature.\n\n### .unencode\n\n def self.unencode(value) -\u003e String\n\nConverts a percent-encoded String to an unencoded value. \n**Parameter**\n\n- **value** (#to_str) --- The percent-encoded `String` to be unencoded. \n**Returns**\n\n- (String) --- The unencoded value.\n\n### .unsigned_resource_parameters\n\n def self.unsigned_resource_parameters(options = {}) -\u003e Array\n\nGenerates an OAuth parameter list to be used when requesting a\nprotected resource. \n**Parameter**\n\n- **options** (Hash) ---\n\n The configuration parameters for the request.\n - `:client_credential_key` - The client credential key.\n - `:token_credential_key` - The token credential key.\n - `:signature_method` - The signature method. Defaults to `'HMAC-SHA1'`.\n- `:two_legged` - A switch for two-legged OAuth. Defaults to `false`. \n**Returns**\n\n- (Array) --- The parameter list as an `Array` of key/value pairs. \n**Raises**\n\n- (ArgumentError)\n\n### .unsigned_temporary_credential_parameters\n\n def self.unsigned_temporary_credential_parameters(options = {}) -\u003e Array\n\nGenerates an OAuth parameter list to be used when obtaining a set of\ntemporary credentials. \n**Parameter**\n\n- **options** (Hash) ---\n\n The configuration parameters for the request.\n - `:client_credential_key` - The client credential key.\n - `:callback` - The OAuth callback. Defaults to [OUT_OF_BAND](/ruby/docs/reference/signet/latest/Signet-OAuth1#Signet__OAuth1__OUT_OF_BAND \"Signet::OAuth1::OUT_OF_BAND (constant)\").\n - `:signature_method` - The signature method. Defaults to `'HMAC-SHA1'`.\n- `:additional_parameters` - Non-standard additional parameters. \n**Returns**\n\n- (Array) --- The parameter list as an `Array` of key/value pairs. \n**Raises**\n\n- (ArgumentError)\n\n### .unsigned_token_credential_parameters\n\n def self.unsigned_token_credential_parameters(options = {}) -\u003e Array\n\nGenerates an OAuth parameter list to be used when obtaining a set of\ntoken credentials. \n**Parameter**\n\n- **options** (Hash) ---\n\n The configuration parameters for the request.\n - `:client_credential_key` - The client credential key.\n - `:temporary_credential_key` - The temporary credential key.\n - `:verifier` - The OAuth verifier.\n- `:signature_method` - The signature method. Defaults to `'HMAC-SHA1'`. \n**Returns**\n\n- (Array) --- The parameter list as an `Array` of key/value pairs. \n**Raises**\n\n- (ArgumentError)\n\nConstants\n---------\n\n### OUT_OF_BAND\n\n**value:**\"oob\".freeze"]]