omniauth-renren-hi54yt 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,89 @@
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 => 'http://graph.renren.com/oauth/authorize',
10
+ :token_url => 'http://graph.renren.com/oauth/token',
11
+ :site => 'http://graph.renren.com'
12
+ }
13
+
14
+ uid { raw_info['uid'] }
15
+
16
+ info do
17
+ {
18
+ "uid" => raw_info["uid"],
19
+ 'name' => raw_info['name'],
20
+ "sex"=> (raw_info["sex"] == 1 ? 'Male' : 'Female'),
21
+ "star"=>raw_info["star"],
22
+ "tinyurl"=>raw_info["tinyurl"],
23
+ "headurl"=>raw_info["headurl"],
24
+ "mainurl"=>raw_info["mainurl"],
25
+ "university_name"=>raw_info["university_history"]["name"],
26
+ "university_year"=>raw_info["university_history"]["year"],
27
+ "university_department"=>raw_info["university_history"]["department"],
28
+ 'urls' => {
29
+ 'Renren' => "http://www.renren.com/profile.do?id="+raw_info["uid"].to_s
30
+ }
31
+ }
32
+ end
33
+
34
+ extra do
35
+ { :raw_info => raw_info }
36
+ end
37
+
38
+ def signed_params
39
+ params = {}
40
+ params[:api_key] = client.id
41
+ params[:method] = 'users.getInfo'
42
+ params[:call_id] = Time.now.to_i
43
+ params[:format] = 'json'
44
+ params[:v] = '1.0'
45
+ params[:uids] = session_key['user']['id']
46
+ params[:session_key] = session_key['renren_token']['session_key']
47
+ params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + client.secret)
48
+ params
49
+ end
50
+
51
+ def session_key
52
+ response = @access_token.get('/renren_api/session_key', {:params => {:oauth_token => @access_token.token}})
53
+ @session_key ||= MultiJson.decode(response.response.env[:body])
54
+ end
55
+
56
+ #http://wiki.dev.renren.com/wiki/%E6%9D%83%E9%99%90%E5%88%97%E8%A1%A8
57
+ def request_phase
58
+ options[:scope] ||= 'publish_feed'
59
+ super
60
+ end
61
+
62
+ def build_access_token
63
+ if renren_session.nil? || renren_session.empty?
64
+ verifier = request.params['code']
65
+ self.access_token = client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options))
66
+ self.access_token
67
+ else
68
+ self.access_token = ::OAuth2::AccessToken.new(client, renren_session['access_token'])
69
+ end
70
+ end
71
+
72
+ def renren_session
73
+ session_cookie = request.cookies["rrs_#{client.id}"]
74
+ if session_cookie
75
+ @renren_session ||= Rack::Utils.parse_query(request.cookies["rrs_#{client.id}"].gsub('"', ''))
76
+ else
77
+ nil
78
+ end
79
+ end
80
+
81
+ def raw_info
82
+ @raw_info ||= MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), signed_params).body)[0]
83
+ @raw_info
84
+ rescue ::Errno::ETIMEDOUT
85
+ raise ::Timeout::Error
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Renren
3
+ VERSION = "1.0.0.rc2.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-renren/version"
2
+ require 'omniauth/strategies/renren'
@@ -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-hi54yt"
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-hi54yt"
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,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-renren-hi54yt
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc2.1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Scott Ballantyne
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0.rc2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0.rc2
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0.rc2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0.rc2
46
+ description: an omniauth strategy for renren
47
+ email:
48
+ - ussballantyne@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - README.rdoc
56
+ - Rakefile
57
+ - lib/omniauth-renren.rb
58
+ - lib/omniauth-renren/version.rb
59
+ - lib/omniauth/strategies/renren.rb
60
+ - omniauth-renren.gemspec
61
+ homepage: ''
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>'
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.1
79
+ requirements: []
80
+ rubyforge_project: omniauth-renren-hi54yt
81
+ rubygems_version: 1.8.24
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: an omniauth strategy for renren
85
+ test_files: []