Sha256: 9b150f1bd73a3429a53351fc4e77dbd57580931b27da3ffde8d6fa86f70955e9

Contents?: true

Size: 878 Bytes

Versions: 7

Compression:

Stored size: 878 Bytes

Contents

require 'openssl'
require 'signet'

module Signet #:nodoc:
  module OAuth1
    module HMACSHA1
      def self.generate_signature(
          base_string, client_credential_secret, token_credential_secret)
        # Both the client secret and token secret must be escaped
        client_credential_secret =
          Signet::OAuth1.encode(client_credential_secret)
        token_credential_secret =
          Signet::OAuth1.encode(token_credential_secret)
        # The key for the signature is just the client secret and token
        # secret joined by the '&' character.  If the token secret is omitted,
        # the '&' must still be present.
        key = [client_credential_secret, token_credential_secret].join("&")
        return Base64.encode64(OpenSSL::HMAC.digest(
            OpenSSL::Digest.new('sha1'), key, base_string
        )).strip
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
signet-0.11.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.10.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.9.2 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.9.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.9.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.8.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.8.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb