roauth 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/README.markdown CHANGED
@@ -2,37 +2,39 @@ Based on SOAuth: http://github.com/tofumatt/SOAuth
2
2
 
3
3
  A *simple* OAuth library that supports OAuth header signing, and header verifying.
4
4
 
5
- gem install roauth
5
+ gem install roauth
6
6
 
7
7
  Example Client:
8
8
 
9
- uri = 'https://twitter.com/direct_messages.json'
10
- oauth = {
11
- :consumer_key => "consumer_key",
12
- :consumer_secret => "consumer_secret",
13
- :access_key => "access_key",
14
- :access_secret => "access_secret"
15
- }
16
- params = {
17
- 'count' => "11",
18
- 'since_id' => "5000"
19
- }
20
- oauth_header = ROAuth.header(oauth, uri, params)
21
-
22
- http_uri = URI.parse(uri)
23
- request = Net::HTTP.new(http_uri.host, http_uri.port)
24
- request.get(uri.request_uri, {'Authorization', oauth_header})
9
+ uri = "https://twitter.com/direct_messages.json"
10
+
11
+ oauth = {
12
+ :consumer_key => "consumer_key",
13
+ :consumer_secret => "consumer_secret",
14
+ :access_key => "access_key",
15
+ :access_secret => "access_secret"
16
+ }
17
+
18
+ params = {
19
+ :count => "11",
20
+ :since_id => "5000"
21
+ }
22
+ oauth_header = ROAuth.header(oauth, uri, params)
23
+
24
+ http_uri = URI.parse(uri)
25
+ request = Net::HTTP.new(http_uri.host, http_uri.port)
26
+ request.get(uri.request_uri, {'Authorization', oauth_header})
25
27
 
26
28
  Example Server:
27
-
28
- oauth_header = ROAuth.parse(request.header['Authorization'])
29
-
30
- # Implementation specific
31
- consumer = Consumer.find_by_key(oauth_header[:consumer_key])
32
- access_token = AccessToken.find_by_token(oauth_header[:access_key])
33
- oauth = {
34
- :consumer_secret => consumer.secret,
35
- :access_secret => access_token.secret
36
- }
37
-
38
- ROAuth.verify(oauth, oauth_header, request.request_uri, params) #=> true/false
29
+
30
+ oauth_header = ROAuth.parse(request.header['Authorization'])
31
+
32
+ # Implementation specific
33
+ consumer = Consumer.find_by_key(oauth_header[:consumer_key])
34
+ access_token = AccessToken.find_by_token(oauth_header[:access_key])
35
+ oauth = {
36
+ :consumer_secret => consumer.secret,
37
+ :access_secret => access_token.secret
38
+ }
39
+
40
+ ROAuth.verify(oauth, oauth_header, request.request_uri, params) #=> true/false
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "roauth"
5
+ gemspec.summary = "Simple Ruby OAuth library"
6
+ gemspec.email = "info@eribium.org"
7
+ gemspec.homepage = "http://github.com/maccman/roauth"
8
+ gemspec.description = "Simple Ruby OAuth library"
9
+ gemspec.authors = ["Alex MacCaw"]
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
data/lib/roauth.rb CHANGED
@@ -19,9 +19,10 @@ module ROAuth
19
19
  oauth[:token] ||= oauth.delete(:access_key)
20
20
  oauth[:token_secret] ||= oauth.delete(:access_secret)
21
21
 
22
- sig_params = params.dup
23
- sig_params.merge!(oauth_params(oauth))
24
- sig_params.merge!(:oauth_signature => escape(signature(oauth, uri, sig_params, http_method)))
22
+ sig_params = oauth_params(oauth)
23
+ sig_params[:oauth_signature] = escape(
24
+ signature(oauth, uri, sig_params.merge(params), http_method)
25
+ )
25
26
 
26
27
  %{OAuth } + sig_params.map {|key, value| [key, value].join("=") }.join(", ")
27
28
  end
@@ -44,8 +45,11 @@ module ROAuth
44
45
  header = header.is_a?(String) ? parse(header) : header.dup
45
46
 
46
47
  client_signature = header.delete(:signature)
47
- oauth[:consumer_key] ||= header[:consumer_key]
48
- oauth[:token] ||= header[:token]
48
+ oauth[:consumer_key] ||= header[:consumer_key]
49
+ oauth[:token] ||= header[:token]
50
+ oauth[:token_secret] ||= oauth.delete(:access_secret)
51
+ oauth[:signature_method] ||= "HMAC-SHA1"
52
+ oauth[:version] ||= "1.0"
49
53
 
50
54
  sig_params = params.dup
51
55
  sig_params.merge!(oauth_params(header))
@@ -69,9 +73,6 @@ module ROAuth
69
73
  digest = SIGNATURE_METHODS[oauth[:signature_method]]
70
74
  secret = "#{escape(oauth[:consumer_secret])}&#{escape(oauth[:token_secret])}"
71
75
 
72
- puts "Secret: #{secret}"
73
- puts "Sigbase: #{sig_base}"
74
-
75
76
  Base64.encode64(OpenSSL::HMAC.digest(digest, secret, sig_base)).chomp.gsub(/\n/, "")
76
77
  end
77
78
 
data/roauth.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{roauth}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alex MacCaw"]
12
+ s.date = %q{2010-03-18}
13
+ s.description = %q{Simple Ruby OAuth library}
14
+ s.email = %q{info@eribium.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.markdown",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/roauth.rb",
26
+ "roauth.gemspec"
27
+ ]
28
+ s.homepage = %q{http://github.com/maccman/roauth}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.6}
32
+ s.summary = %q{Simple Ruby OAuth library}
33
+
34
+ if s.respond_to? :specification_version then
35
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
39
+ else
40
+ end
41
+ else
42
+ end
43
+ end
44
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Alex MacCaw
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-20 00:00:00 +00:00
17
+ date: 2010-03-18 00:00:00 +00:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -23,9 +28,13 @@ extra_rdoc_files:
23
28
  - LICENSE
24
29
  - README.markdown
25
30
  files:
31
+ - .gitignore
26
32
  - LICENSE
27
33
  - README.markdown
34
+ - Rakefile
35
+ - VERSION
28
36
  - lib/roauth.rb
37
+ - roauth.gemspec
29
38
  has_rdoc: true
30
39
  homepage: http://github.com/maccman/roauth
31
40
  licenses: []
@@ -39,18 +48,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
48
  requirements:
40
49
  - - ">="
41
50
  - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
42
53
  version: "0"
43
- version:
44
54
  required_rubygems_version: !ruby/object:Gem::Requirement
45
55
  requirements:
46
56
  - - ">="
47
57
  - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
48
60
  version: "0"
49
- version:
50
61
  requirements: []
51
62
 
52
63
  rubyforge_project:
53
- rubygems_version: 1.3.5
64
+ rubygems_version: 1.3.6
54
65
  signing_key:
55
66
  specification_version: 3
56
67
  summary: Simple Ruby OAuth library