Class: Header

Inherits:
Object
  • Object
show all
Defined in:
lib/header.rb

Overview

Formats HTTP Authorization header.

https://dev.twitter.com/oauth/overview/authorizing-requests

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oauth_token, signature, nonce, epochtime) ⇒ Header

Returns a new instance of Header.



14
15
16
17
18
19
20
# File 'lib/header.rb', line 14

def initialize(oauth_token, signature, nonce, epochtime)
  @oauth_token = oauth_token
  @signature = signature

  @nonce = nonce
  @epochtime = epochtime
end

Class Method Details

.keyObject



10
11
12
# File 'lib/header.rb', line 10

def self.key
  'Authorization'
end

Instance Method Details

#valueObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/header.rb', line 22

def value
  <<-EOF
  OAuth #{escape('oauth_consumer_key')}="#{escape(TwitterRequestHeaders.consumer_key)}",
        #{escape('oauth_nonce')}="#{escape(@nonce)}",
        #{escape('oauth_signature')}="#{escape(@signature)}",
        #{escape('oauth_signature_method')}="#{escape(TwitterRequestHeaders.oauth_cipher)}",
        #{escape('oauth_timestamp')}="#{escape(@epochtime)}",
        #{escape('oauth_token')}="#{escape(@oauth_token)}",
        #{escape('oauth_version')}="#{escape(TwitterRequestHeaders.oauth_version)}"
  EOF
end