Sha256: f9f8df379f79fb7c67ab92eb681771d53a4794c0d6cc4f30107b05275f6ae527

Contents?: true

Size: 964 Bytes

Versions: 29

Compression:

Stored size: 964 Bytes

Contents

begin
  require 'digest/hmac'
rescue LoadError
  require 'compat/digest/hmac'
end
require 'digest/sha1'
require 'base64'

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(Digest::HMAC.digest(
          base_string, key, Digest::SHA1
        )).strip
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
signet-0.7.3 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.7.2 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.7.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.7.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.6.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.6.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.5.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.5.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.5 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.4 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.3 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.2 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.4.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.3.4 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.3.3 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.3.2 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.3.1 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.3.0 lib/signet/oauth_1/signature_methods/hmac_sha1.rb
signet-0.2.4 lib/signet/oauth_1/signature_methods/hmac_sha1.rb