omniauth-renren-ex 1.0.0.rc2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-renren.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,36 @@
1
+ = omniauth-renren
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Scott Ballantyne, Transi.st
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining
20
+ a copy of this software and associated documentation files (the
21
+ "Software"), to deal in the Software without restriction, including
22
+ without limitation the rights to use, copy, modify, merge, publish,
23
+ distribute, sublicense, and/or sell copies of the Software, and to
24
+ permit persons to whom the Software is furnished to do so, subject to
25
+ the following conditions:
26
+
27
+ The above copyright notice and this permission notice shall be
28
+ included in all copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-renren/version"
2
+ require 'omniauth/strategies/renren'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Renren
3
+ VERSION = "1.0.0.rc2.1"
4
+ end
5
+ end
@@ -0,0 +1,78 @@
1
+ # lots of stuff taken from https://github.com/yzhang/omniauth/commit/eafc5ff8115bcc7d62c461d4774658979dd0a48e
2
+
3
+ require 'omniauth-oauth2'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Renren < OmniAuth::Strategies::OAuth2
8
+ option :client_options, {
9
+ :authorize_url => '/oauth/authorize',
10
+ :token_url => '/oauth/token',
11
+ :site => 'http://graph.renren.com/'
12
+ }
13
+ def request_phase
14
+ super
15
+ end
16
+
17
+ uid { raw_info['uid'] }
18
+
19
+ info do
20
+ {
21
+ "uid" => raw_info["uid"],
22
+ "gender"=> (raw_info['gender'] == '0' ? 'Male' : 'Female'),
23
+ "image"=>raw_info['logo50'],
24
+ 'name' => raw_info['name'],
25
+ 'urls' => {
26
+ 'Kaixin' => "http://www.kaixin001.com/"
27
+ }
28
+ }
29
+ end
30
+
31
+ def signed_params
32
+ params = {}
33
+ params[:api_key] = client.id
34
+ params[:method] = 'users.getInfo'
35
+ params[:call_id] = Time.now.to_i
36
+ params[:format] = 'json'
37
+ params[:v] = '1.0'
38
+ params[:uids] = session_key['user']['id']
39
+ params[:session_key] = session_key['renren_token']['session_key']
40
+ params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + client.secret)
41
+ params
42
+ end
43
+
44
+ def session_key
45
+ @session_key ||= MultiJson.decode(@access_token.get("/renren_api/session_key?oauth_token=#{@access_token.token}").body)
46
+ end
47
+
48
+ def request_phase
49
+ options[:scope] ||= 'publish_feed'
50
+ super
51
+ end
52
+
53
+ def build_access_token
54
+ if renren_session.nil? || renren_session.empty?
55
+ super
56
+ else
57
+ @access_token = ::OAuth2::AccessToken.new(client, renren_session['access_token'])
58
+ end
59
+ end
60
+
61
+ def renren_session
62
+ session_cookie = request.cookies["rrs_#{client.id}"]
63
+ if session_cookie
64
+ @renren_session ||= Rack::Utils.parse_query(request.cookies["rrs_#{client.id}"].gsub('"', ''))
65
+ else
66
+ nil
67
+ end
68
+ end
69
+
70
+ def raw_info
71
+ @raw_info ||= MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), signed_params).body)[0]
72
+ @raw_info
73
+ rescue ::Errno::ETIMEDOUT
74
+ raise ::Timeout::Error
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-renren/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-renren-ex"
7
+ s.version = Omniauth::Renren::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for renren}
12
+ s.description = %q{an omniauth strategy for renren}
13
+
14
+ s.rubyforge_project = "omniauth-renren"
15
+ s.add_dependency 'omniauth', '~> 1.0.0.rc2'
16
+ s.add_dependency 'omniauth-oauth2', '~> 1.0.0.rc2'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ # s.add_development_dependency "rspec"
25
+ # s.add_runtime_dependency "rest-client"
26
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-renren-ex
3
+ version: !ruby/object:Gem::Version
4
+ hash: 30848161
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ - rc
11
+ - 2
12
+ - 1
13
+ version: 1.0.0.rc2.1
14
+ platform: ruby
15
+ authors:
16
+ - Scott Ballantyne
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2011-11-29 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: omniauth
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 15424049
32
+ segments:
33
+ - 1
34
+ - 0
35
+ - 0
36
+ - rc
37
+ - 2
38
+ version: 1.0.0.rc2
39
+ type: :runtime
40
+ version_requirements: *id001
41
+ - !ruby/object:Gem::Dependency
42
+ name: omniauth-oauth2
43
+ prerelease: false
44
+ requirement: &id002 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 15424049
50
+ segments:
51
+ - 1
52
+ - 0
53
+ - 0
54
+ - rc
55
+ - 2
56
+ version: 1.0.0.rc2
57
+ type: :runtime
58
+ version_requirements: *id002
59
+ description: an omniauth strategy for renren
60
+ email:
61
+ - ussballantyne@gmail.com
62
+ executables: []
63
+
64
+ extensions: []
65
+
66
+ extra_rdoc_files: []
67
+
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - README.rdoc
72
+ - Rakefile
73
+ - lib/omniauth-renren.rb
74
+ - lib/omniauth-renren/version.rb
75
+ - lib/omniauth/strategies/renren.rb
76
+ - omniauth-renren.gemspec
77
+ homepage: ""
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options: []
82
+
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">"
98
+ - !ruby/object:Gem::Version
99
+ hash: 25
100
+ segments:
101
+ - 1
102
+ - 3
103
+ - 1
104
+ version: 1.3.1
105
+ requirements: []
106
+
107
+ rubyforge_project: omniauth-renren
108
+ rubygems_version: 1.8.11
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: an omniauth strategy for renren
112
+ test_files: []
113
+