omniauth-renren-oauth2 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 844acdbe57f84d0d73c7e018cf712a1352118119
4
+ data.tar.gz: 2fb729cb6bdf413469804dbbfecaa36a2ee53397
5
+ SHA512:
6
+ metadata.gz: d6708a84a4426f82bf12b4e836465378a125a3071038e9895e5b1cf23a2ba4a5596ba31fb663916e5bce1e202925873419dd781538ec984fc248d7766e297517
7
+ data.tar.gz: d617f3bf4cba512e31ec3ab4a4bc2d2330e0623dcb91db1922c928445d1a4f6e6284bdd861b76b902849bec496baac65761c37a81c4b122424bdf84393a23a09
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
19
+ *.swo
20
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-renren2.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 ye.li
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Omniauth Renren Oauth 2
2
+
3
+ Renren oauth2 stragy form omniauth 1.0
4
+
5
+ Read Renren Oauth2 docs form more details: [http://wiki.dev.renren.com/wiki](http://wiki.dev.renren.com/wiki)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-renren-oauth2'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-renren-oauth2
20
+
21
+ ## Usage
22
+
23
+ OmniAuth::Strategies::RenRen is simply a Rack middleware. Read the OmniAuth 1.0 docs for details instructions: [https://github.com/intridea/omniauth](https://github.com/intridea/omniauth)
24
+
25
+ Here's a quick example, adding the middleware to Rails app in config/initializers/omniauth.rb
26
+
27
+
28
+ ```ruby
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :renren, ENV['RENREN_KEY'], ENV['RENREN_SECRET']
31
+ end
32
+ ```
33
+
34
+ ## Configuring
35
+ * `scope`: comma-separated list of permissions you want to request from the user. See the Renren docs for a full list for available permissions: [http://wiki.dev.renren.com/wiki/%E6%9D%83%E9%99%90%E5%88%97%E8%A1%A8](http://wiki.dev.renren.com/wiki/%E6%9D%83%E9%99%90%E5%88%97%E8%A1%A8)
36
+
37
+ ```ruby
38
+ Rails.application.config.middleware.use OmniAuth::Builder do
39
+ provider :renren, ENV['RENREN_KEY'], ENV['RENREN_SECRET'], :scope => 'read_user_feed read_user_status publish_feed publish_share'
40
+ end
41
+ ```
42
+
43
+
44
+
45
+ ## Auth Hash
46
+ Here's an example Auth Hash available in `request.env['omniauth.auth']`
47
+
48
+ ```ruby
49
+
50
+ {"provider"=>"renren",
51
+ "uid"=> "123456789",
52
+ "info"=> {
53
+ "uid"=>"123456789",
54
+ "gender"=>"Male",
55
+ "image"=>"http://hdn.xnimg.cn/photos/1.jpg",
56
+ "name"=>"test",
57
+ "urls"=>{"Renren"=>"http://www.renren.com/222159293/profile"}},
58
+ "credentials"=>{"token"=>"230086|32csdfg435...",
59
+ "refresh_token"=>"230086|32csdfg435...",
60
+ "expires_at"=>1366628401,
61
+ "expires"=>true
62
+ },
63
+ "extra"=>{
64
+ "raw_info"=>{
65
+ "uid"=> "123456789",
66
+ "tinyurl"=>"http://hdn.xnimg.cn/photos/1.jpg",
67
+ "vip"=>1,
68
+ "sex"=>1,
69
+ "name"=>"test",
70
+ "star"=>0,
71
+ "headurl"=>"http://hdn.xnimg.cn/photos/1.jpg",
72
+ "zidou"=>0
73
+ }
74
+ }
75
+ }
76
+
77
+ ```
78
+
79
+ The precise information available may depend on the permissions which you request.
80
+
81
+ ## Contributing
82
+
83
+ 1. Fork it
84
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
85
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
86
+ 4. Push to the branch (`git push origin my-new-feature`)
87
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,41 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Renren < OmniAuth::Strategies::OAuth2
7
+ option :client_options, {
8
+ :site => 'http://graph.renren.com',
9
+ :authorize_url => '/oauth/authorize',
10
+ :token_url => '/oauth/token'
11
+ }
12
+
13
+ uid { raw_info['uid'] }
14
+
15
+ info do
16
+ {
17
+ "uid" => raw_info["uid"],
18
+ "gender"=> (raw_info["sex"] == 1 ? 'Male' : 'Female'),
19
+ "image"=>raw_info["headurl"],
20
+ 'name' => raw_info['name'],
21
+ 'urls' => {
22
+ 'Renren' => "http://www.renren.com/#{raw_info["uid"]}/profile"
23
+ }
24
+ }
25
+ end
26
+
27
+ extra do
28
+ {
29
+ :raw_info => raw_info
30
+ }
31
+ end
32
+
33
+ def raw_info
34
+ access_token.options[:mode] = :query
35
+ access_token.options[:param_name] = 'access_token'
36
+ params ||= { :v => "1.0", :format => "json", :call_id => Time.now.to_i, :method => "users.getInfo" }
37
+ @raw_info ||= MultiJson.decode(access_token.post( "https://api.renren.com/restserver.do", body: params).body)[0]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module RenrenOauth2
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require "omniauth-renren-oauth2/version"
2
+ require 'omniauth/strategies/renren'
3
+
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-renren-oauth2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-renren-oauth2"
8
+ spec.authors = ["ye.li"]
9
+ spec.email = ["yeeli@outlook.com"]
10
+ spec.description = %q{OmniAuth Oauth2 strategy for renren.com}
11
+ spec.summary = %q{OmniAuth Oauth2 strategy for renren.com}
12
+ spec.homepage = "https://github.com/yeeli/omniauth-renren-oauth2"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+ spec.version = OmniAuth::RenrenOauth2::VERSION
19
+
20
+ spec.add_dependency 'omniauth', '~> 1.1'
21
+ spec.add_dependency 'omniauth-oauth2', '~> 1.1'
22
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-renren-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ye.li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ description: OmniAuth Oauth2 strategy for renren.com
42
+ email:
43
+ - yeeli@outlook.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/omniauth-renren-oauth2.rb
54
+ - lib/omniauth-renren-oauth2/version.rb
55
+ - lib/omniauth/strategies/renren.rb
56
+ - omniauth-renren-oauth2.gemspec
57
+ homepage: https://github.com/yeeli/omniauth-renren-oauth2
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.0.0
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: OmniAuth Oauth2 strategy for renren.com
80
+ test_files: []
81
+ has_rdoc: