omniauth-xiaonei 0.0.2
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 +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +19 -0
- data/Rakefile +1 -0
- data/lib/omniauth/renren/version.rb +5 -0
- data/lib/omniauth/renren.rb +2 -0
- data/lib/omniauth/strategies/renren.rb +74 -0
- data/lib/omniauth-renren.rb +2 -0
- data/omniauth-renren.gemspec +27 -0
- metadata +86 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= Omniauth-renren
|
2
|
+
|
3
|
+
Omniauth strategy for renren[http://www.renren.com]
|
4
|
+
|
5
|
+
= Usage
|
6
|
+
|
7
|
+
Please refer to Omniauth[https://github.com/intridea/omniauth/] for usage
|
8
|
+
|
9
|
+
= Thanks
|
10
|
+
|
11
|
+
Author(s) of Omniauth-facebook and Omniauth.
|
12
|
+
|
13
|
+
= License
|
14
|
+
|
15
|
+
MIT License
|
16
|
+
|
17
|
+
= Copyright
|
18
|
+
|
19
|
+
Copyright (c) Jie Fan.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "digest/md5"
|
3
|
+
require "omniauth/strategies/oauth2"
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Renren < OmniAuth::Strategies::OAuth2
|
8
|
+
option :name, "renren"
|
9
|
+
|
10
|
+
option :client_options, {
|
11
|
+
:site => "https://graph.renren.com"
|
12
|
+
}
|
13
|
+
|
14
|
+
option :token_params, {
|
15
|
+
:grant_type => "authorization_code"
|
16
|
+
}
|
17
|
+
|
18
|
+
#option :api_url, "http://api.renren.com/restserver.do"
|
19
|
+
|
20
|
+
def request_phase
|
21
|
+
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params))
|
22
|
+
end
|
23
|
+
|
24
|
+
def raw_info
|
25
|
+
opts = {
|
26
|
+
:method => "users.getInfo",
|
27
|
+
:v => "1.0",
|
28
|
+
:format => "JSON",
|
29
|
+
:access_token => access_token.token
|
30
|
+
}.merge!(fields)
|
31
|
+
conn = Faraday.new(:url => "http://api.renren.com") do |faraday|
|
32
|
+
faraday.request :url_encoded
|
33
|
+
faraday.response :logger
|
34
|
+
faraday.adapter Faraday.default_adapter
|
35
|
+
end
|
36
|
+
@raw_info ||= parse(conn.post("/restserver.do", append_sig(opts)).body).first || {}
|
37
|
+
end
|
38
|
+
|
39
|
+
uid {
|
40
|
+
raw_info[:uid.to_s]
|
41
|
+
}
|
42
|
+
|
43
|
+
info {
|
44
|
+
(options[:fields] || "name,email_hash,tinyurl,headurl,zidou,star").split(",").inject({}) { |t,v| t[v.to_sym] = raw_info[v];t }
|
45
|
+
}
|
46
|
+
|
47
|
+
extra {
|
48
|
+
hash = {}
|
49
|
+
hash["raw_info"] = raw_info unless skip_info?
|
50
|
+
prune! hash
|
51
|
+
}
|
52
|
+
|
53
|
+
private
|
54
|
+
def append_sig(opts = {})
|
55
|
+
opts.merge!({ :sig => Digest::MD5.hexdigest(opts.inject([]) { |t, v| t << v.join("=") }.sort.join + options.client_secret) })
|
56
|
+
end
|
57
|
+
|
58
|
+
def fields
|
59
|
+
options[:fields] ? { :fields => options[:fields] } : {}
|
60
|
+
end
|
61
|
+
|
62
|
+
def prune!(hash)
|
63
|
+
hash.delete_if do |_, value|
|
64
|
+
prune!(value) if value.is_a?(Hash)
|
65
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def parse(content)
|
70
|
+
lambda { |body| MultiJson.respond_to?(:adapter) ? MultiJson.load(body) : MultiJson.decode(body) rescue body }.call(content)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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-xiaonei"
|
7
|
+
s.version = Omniauth::Renren::VERSION
|
8
|
+
s.authors = ["Jie Fan"]
|
9
|
+
s.email = ["ustc.flyingfox@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/lastomato/omniauth-xiaonei"
|
11
|
+
s.summary = %q{Omniauth strategy for Renren}
|
12
|
+
s.description = %q{Omniauth strategy for Renren}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-renren"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
s.add_runtime_dependency "omniauth-oauth2"
|
25
|
+
|
26
|
+
s.add_development_dependency "rspec"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-xiaonei
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jie Fan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Omniauth strategy for Renren
|
47
|
+
email:
|
48
|
+
- ustc.flyingfox@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.rb
|
59
|
+
- lib/omniauth/renren/version.rb
|
60
|
+
- lib/omniauth/strategies/renren.rb
|
61
|
+
- omniauth-renren.gemspec
|
62
|
+
homepage: https://github.com/lastomato/omniauth-xiaonei
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project: omniauth-renren
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Omniauth strategy for Renren
|
86
|
+
test_files: []
|