omniauth-kaixin 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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-kaixin.gemspec
4
+ gemspec
data/README ADDED
File without changes
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-kaixin/version"
2
+ require 'omniauth/strategies/kaixin'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Kaixin
3
+ VERSION = "1.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,128 @@
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 Kaixin < OmniAuth::Strategies::OAuth2
8
+ option :client_options, {
9
+ :site => 'https://api.kaixin001.com/',
10
+ :authorize_url => '/oauth2/authorize',
11
+ :token_url => '/oauth2/access_token',
12
+ :token_method => :get
13
+ }
14
+ def request_phase
15
+ super
16
+ end
17
+
18
+ uid { raw_info['uid'] }
19
+
20
+ info do
21
+ {
22
+ "uid" => raw_info["uid"],
23
+ "gender"=> (raw_info['gender'] == '0' ? 'Male' : 'Female'),
24
+ "image"=>raw_info['logo50'],
25
+ 'name' => raw_info['name'],
26
+ 'urls' => {
27
+ 'Kaixin' => "http://www.kaixin001.com/"
28
+ }
29
+ }
30
+ end
31
+
32
+ def raw_info
33
+ @raw_info ||= MultiJson.decode(access_token.get("/users/me.json?access_token=#{@access_token.token}").body)
34
+ puts @raw_info.inspect
35
+ @raw_info
36
+ rescue ::Errno::ETIMEDOUT
37
+ raise ::Timeout::Error
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ # require 'omniauth/strategies/oauth2'
44
+ #
45
+ # module OmniAuth
46
+ # module Strategies
47
+ #
48
+ # # Authenticate to Kaixin001 utilizing OAuth 2.0 and retrieve
49
+ # # basic user information.
50
+ # #
51
+ # # OAuth 2.0 - Kaixin001 Documentation
52
+ # # http://wiki.open.kaixin001.com/
53
+ # #
54
+ # # Apply kaixin001 key here:
55
+ # # http://www.kaixin001.com/platform/rapp/rapp.php
56
+ # # adapted from https://github.com/yzhang/omniauth/commit/eafc5ff8115bcc7d62c461d4774658979dd0a48e
57
+ #
58
+ # class Kaixin < OmniAuth::Strategies::OAuth2
59
+ # def initialize(*args)
60
+ # super
61
+ # # taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tqq.rb#L15-24
62
+ # puts options.inspect
63
+ # options.client_options = {
64
+ # :site => 'https://api.kaixin001.com/',
65
+ # :authorize_url => '/oauth2/authorize',
66
+ # :token_url => '/oauth2/access_token',
67
+ # :token_method => :get
68
+ # }
69
+ # end
70
+ #
71
+ # info do
72
+ # {
73
+ # :uid => raw_info['uid'],
74
+ # :user_info => raw_info['data']['name'],
75
+ # :location => raw_info['data']['location'],
76
+ # :image => raw_info['data']['head'],
77
+ # :description => raw_info['description'],
78
+ # :extra => {
79
+ # 'user_hash' => user_data,
80
+ # }
81
+ # }
82
+ # end
83
+ #
84
+ # extra do
85
+ # { :raw_info => raw_info }
86
+ # end
87
+ #
88
+ # def callback_phase
89
+ #
90
+ # if request.params['error'] || request.params['error_reason']
91
+ # raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])
92
+ # end
93
+ #
94
+ # self.access_token = build_access_token
95
+ # self.access_token = client.auth_code.refresh_token(access_token.refresh_token) if access_token.expired?
96
+ #
97
+ # super
98
+ # rescue ::OAuth2::Error, CallbackError => e
99
+ # fail!(:invalid_credentials, e)
100
+ # rescue ::MultiJson::DecodeError => e
101
+ # fail!(:invalid_response, e)
102
+ # rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
103
+ # fail!(:timeout, e)
104
+ # end
105
+ #
106
+ # credentials do
107
+ # prune!({
108
+ # 'expires' => access_token.expires?,
109
+ # 'expires_at' => access_token.expires_at
110
+ # })
111
+ # end
112
+ #
113
+ # def user_info
114
+ # {
115
+ # 'uid' => raw_info['uid'],
116
+ # 'name' => raw_info['name'],
117
+ # 'gender' => raw_info['gender'],
118
+ # }
119
+ # end
120
+ #
121
+ # def raw_info
122
+ # @raw_info ||= MultiJson.decode(access_token.get("/users/me.json?access_token=#{@access_token.token}").body)
123
+ # rescue ::Errno::ETIMEDOUT
124
+ # raise ::Timeout::Error
125
+ # end
126
+ # end
127
+ # end
128
+ # end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-kaixin/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-kaixin"
7
+ s.version = Omniauth::Kaixin::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for kaixin001}
12
+ s.description = %q{an omniauth strategy for kaixin001}
13
+
14
+ s.rubyforge_project = "omniauth-kaixin"
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,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-kaixin
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1923643363
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 1.0.0.rc2
13
+ platform: ruby
14
+ authors:
15
+ - Scott Ballantyne
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-10-29 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: omniauth
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 1923643363
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 0
35
+ - rc
36
+ - 2
37
+ version: 1.0.0.rc2
38
+ type: :runtime
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: omniauth-oauth2
42
+ prerelease: false
43
+ requirement: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ hash: 1923643363
49
+ segments:
50
+ - 1
51
+ - 0
52
+ - 0
53
+ - rc
54
+ - 2
55
+ version: 1.0.0.rc2
56
+ type: :runtime
57
+ version_requirements: *id002
58
+ description: an omniauth strategy for kaixin001
59
+ email:
60
+ - ussballantyne@gmail.com
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ extra_rdoc_files: []
66
+
67
+ files:
68
+ - .gitignore
69
+ - Gemfile
70
+ - README
71
+ - Rakefile
72
+ - lib/omniauth-kaixin.rb
73
+ - lib/omniauth-kaixin/version.rb
74
+ - lib/omniauth/strategies/kaixin.rb
75
+ - omniauth-kaixin.gemspec
76
+ homepage: ""
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">"
97
+ - !ruby/object:Gem::Version
98
+ hash: 25
99
+ segments:
100
+ - 1
101
+ - 3
102
+ - 1
103
+ version: 1.3.1
104
+ requirements: []
105
+
106
+ rubyforge_project: omniauth-kaixin
107
+ rubygems_version: 1.8.11
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: an omniauth strategy for kaixin001
111
+ test_files: []
112
+