social_oauth_api 0.1.1 → 0.1.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.
- checksums.yaml +5 -13
- data/README.md +16 -3
- data/lib/social_oauth_api/base.rb +3 -2
- data/lib/social_oauth_api/qqdenglu/qqdenglu_user.rb +6 -6
- data/lib/social_oauth_api/version.rb +1 -1
- data/lib/social_oauth_api/weixin/weixin.rb +4 -0
- data/lib/social_oauth_api/weixin/weixin_config.rb +11 -0
- data/lib/social_oauth_api/weixin/weixin_user.rb +31 -0
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YmEzMmVhNTU2YjI1ZGNlNzU5MjI1Yzg0ZDU2MTcyZWM2OWU1OTRlMA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8a1c8536949c4ee53d2d5d2058cd0f8a53fdf172
|
4
|
+
data.tar.gz: c86119a8156e5775f92dce5151b819383a6740e2
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZDNlNjNjMmM1NmNlNzI5ZTFmODgzMGQxMWQzYTkwMWIzMDAzNjRlNmFhNWMx
|
11
|
-
OGM4YmI3MzgzYjg0ZjhiNTQwNzAyNGYxODMzYjVhMmFjYTk4NDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzU1MGQ5ZjlkZDM4ZmUyNTdkOTUwZTQ5NGY5NTU2MzFmM2ZlNTQzY2QzYjc5
|
14
|
-
MTlhZGI0N2M5NjdmMjExYzI1MDRlYzgxYTUwZWZmZGQ5NDZmNmE1OGIyNDA0
|
15
|
-
MTk0NzJmYjk2ODJlYzY3NmEyMzQ5MTIyZDVlNThmYTQ4NWY0NWY=
|
6
|
+
metadata.gz: 75eb237970c25ebd6ec94d3bedca2312b3b1be17bff735dc054d5c23e0ad68af34f1ed4a4e74442b255e18fb8001f22292a68663716170efb0e09d361050fd73
|
7
|
+
data.tar.gz: b219c4cf8a2933c2af4065f4fea9f8f3b819bfa37a6a287d5ad86e46a6c64840522328df1ae246ab28628c0b3ed60f8bf7481a54e0d213847977297aa0d2e807
|
data/README.md
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
|
5
5
|
提供给前后端分离的框架使用
|
6
6
|
|
7
|
-
只接受前端sdk传回来的第三方 **access_token**
|
7
|
+
只接受前端sdk传回来的第三方 **access_token** 参数及其它必须参数
|
8
8
|
|
9
9
|
支持第三方列表如下:
|
10
10
|
|
11
11
|
- 新浪微博
|
12
12
|
- QQ号登录
|
13
|
+
- 微信号登录
|
13
14
|
|
14
15
|
## Installation
|
15
16
|
|
@@ -40,6 +41,12 @@ qq_config = {
|
|
40
41
|
client_id: 'xxxxxxxx' # => 如果只需要user_id, 不需要用户信息可以不传 client_id 参数
|
41
42
|
}
|
42
43
|
|
44
|
+
weixin_config = {
|
45
|
+
provider_type: 'weixin',
|
46
|
+
access_token: 'xxxxxxxxx',
|
47
|
+
openid: 'xxxxxxxx'
|
48
|
+
}
|
49
|
+
|
43
50
|
weibo = SocialOauthApi::User.new(weibo_config)
|
44
51
|
p weibo.id # => weibo uid
|
45
52
|
p weibo.name # => weibo screen_name
|
@@ -47,15 +54,21 @@ p weibo.image_url # => weibo profile_image_url
|
|
47
54
|
p weibo.user_info
|
48
55
|
|
49
56
|
qq = SocialOauthApi::User.new(qq_config)
|
50
|
-
p qq.id # => qq
|
57
|
+
p qq.id # => qq openid
|
51
58
|
p qq.name # => qq nickname
|
52
59
|
p qq.image_url # => qq figureurl
|
53
60
|
p qq.user_info
|
61
|
+
|
62
|
+
weixin = SocialOauthApi::User.new(weixin_config)
|
63
|
+
p weixin.id # => weixin openid
|
64
|
+
p weixin.name # => weixin nickname
|
65
|
+
p weixin.image_url # => weixin headimgurl
|
66
|
+
p weixin.user_info
|
54
67
|
```
|
55
68
|
|
56
69
|
## Contributing
|
57
70
|
|
58
|
-
1. Fork it (
|
71
|
+
1. Fork it ( https://github.com/awesome-api/social_oauth_api/fork )
|
59
72
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
73
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
module SocialOauthApi
|
4
4
|
module Base
|
5
|
-
attr_reader :client_id, :provider_type, :access_token
|
5
|
+
attr_reader :client_id, :openid, :provider_type, :access_token
|
6
6
|
|
7
7
|
HTTP_TIMEOUT = 15
|
8
8
|
|
9
9
|
def initialize options
|
10
10
|
@client_id = options[:client_id]
|
11
|
+
@openid = options[:openid]
|
11
12
|
@provider_type = options[:provider_type]
|
12
13
|
@access_token = options[:access_token]
|
13
14
|
end
|
@@ -32,4 +33,4 @@ module SocialOauthApi
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
35
|
-
end
|
36
|
+
end
|
@@ -6,9 +6,9 @@ module SocialOauthApi
|
|
6
6
|
include SocialOauthApi::Base
|
7
7
|
include SocialOauthApi::Qqdenglu::Config
|
8
8
|
|
9
|
-
def
|
10
|
-
@
|
11
|
-
@
|
9
|
+
def openid
|
10
|
+
@openid ||= get(open_id_url, access_token: access_token)
|
11
|
+
@openid.match(/"openid":"(?<openid>\w+)"/)[:openid]
|
12
12
|
end
|
13
13
|
|
14
14
|
def user_info
|
@@ -16,7 +16,7 @@ module SocialOauthApi
|
|
16
16
|
get(user_info_url,
|
17
17
|
access_token: access_token,
|
18
18
|
oauth_consumer_key: client_id,
|
19
|
-
openid:
|
19
|
+
openid: openid)
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -28,9 +28,9 @@ module SocialOauthApi
|
|
28
28
|
user_info['figureurl']
|
29
29
|
end
|
30
30
|
|
31
|
-
alias :id :
|
31
|
+
alias :id :openid
|
32
32
|
alias :name :nickname
|
33
33
|
alias :image_url :figureurl
|
34
34
|
end
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module SocialOauthApi
|
4
|
+
module Weixin
|
5
|
+
class User
|
6
|
+
include SocialOauthApi::Base
|
7
|
+
include SocialOauthApi::Weixin::Config
|
8
|
+
|
9
|
+
def show
|
10
|
+
@user_info ||= JSON.parse(
|
11
|
+
get(user_info_url,
|
12
|
+
access_token: access_token,
|
13
|
+
openid: openid)
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def nickname
|
18
|
+
show['nickname']
|
19
|
+
end
|
20
|
+
|
21
|
+
def headimgurl
|
22
|
+
show['headimgurl']
|
23
|
+
end
|
24
|
+
|
25
|
+
alias :id :openid
|
26
|
+
alias :name :nickname
|
27
|
+
alias :image_url :headimgurl
|
28
|
+
alias :user_info :show
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_oauth_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spirit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: social oauth for api
|
@@ -45,7 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
@@ -63,6 +63,9 @@ files:
|
|
63
63
|
- lib/social_oauth_api/sinaweibo/sinaweibo_user.rb
|
64
64
|
- lib/social_oauth_api/user.rb
|
65
65
|
- lib/social_oauth_api/version.rb
|
66
|
+
- lib/social_oauth_api/weixin/weixin.rb
|
67
|
+
- lib/social_oauth_api/weixin/weixin_config.rb
|
68
|
+
- lib/social_oauth_api/weixin/weixin_user.rb
|
66
69
|
- social_oauth_api.gemspec
|
67
70
|
homepage: https://github.com/NaixSpirit/social_oauth_api
|
68
71
|
licenses:
|
@@ -74,12 +77,12 @@ require_paths:
|
|
74
77
|
- lib
|
75
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
79
|
requirements:
|
77
|
-
- -
|
80
|
+
- - ">="
|
78
81
|
- !ruby/object:Gem::Version
|
79
82
|
version: '0'
|
80
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
84
|
requirements:
|
82
|
-
- -
|
85
|
+
- - ">="
|
83
86
|
- !ruby/object:Gem::Version
|
84
87
|
version: '0'
|
85
88
|
requirements: []
|
@@ -89,3 +92,4 @@ signing_key:
|
|
89
92
|
specification_version: 4
|
90
93
|
summary: social oauth for api
|
91
94
|
test_files: []
|
95
|
+
has_rdoc:
|