omniauth-vkontakte 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/lib/omniauth-vkontakte/version.rb +1 -1
- data/lib/omniauth/strategies/vkontakte.rb +27 -9
- metadata +2 -2
data/README.md
CHANGED
@@ -27,6 +27,18 @@ use OmniAuth::Builder do
|
|
27
27
|
end
|
28
28
|
```
|
29
29
|
|
30
|
+
### Update to omniauth-oauth2 1.1.0
|
31
|
+
Application raise "invalid credensials" when login. The reason is [csrf protection](https://github.com/intridea/omniauth-oauth2/pull/18) in omniauth-oauth2 1.1.0.
|
32
|
+
Vkontakte doesn't return `state` parameter with the code, if the `scope` doesn't include `notify`.
|
33
|
+
|
34
|
+
The solution is to specify at least the `notify` in parameter `scope`, like so:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
use OmniAuth::Builder do
|
38
|
+
provider :vkontakte, ENV['API_KEY'], ENV['API_SECRET'], :scope => 'notify'
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
30
42
|
## Supported Rubies
|
31
43
|
|
32
44
|
Tested with the following Ruby versions:
|
@@ -34,6 +46,10 @@ Tested with the following Ruby versions:
|
|
34
46
|
- MRI 1.9.3
|
35
47
|
- MRI 1.8.7
|
36
48
|
|
49
|
+
## Contributing to omniauth-vkontakte
|
50
|
+
|
51
|
+
* Fork, fix, then send me a pull request.
|
52
|
+
|
37
53
|
## License
|
38
54
|
|
39
55
|
Copyright (c) 2011, 2012 Anton Maminov
|
@@ -6,7 +6,7 @@ module OmniAuth
|
|
6
6
|
# Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
|
7
7
|
# basic user information.
|
8
8
|
# documentation available here:
|
9
|
-
# http://
|
9
|
+
# http://vk.com/developers.php?o=-17680044&p=Authorization&s=0
|
10
10
|
#
|
11
11
|
# @example Basic Usage
|
12
12
|
# use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
|
@@ -22,11 +22,13 @@ module OmniAuth
|
|
22
22
|
}
|
23
23
|
|
24
24
|
option :access_token_options, {
|
25
|
-
:param_name => 'access_token'
|
25
|
+
:param_name => 'access_token'
|
26
26
|
}
|
27
27
|
|
28
28
|
option :authorize_options, [:scope, :display]
|
29
29
|
|
30
|
+
option :provider_ignores_state, true
|
31
|
+
|
30
32
|
uid { access_token.params['user_id'] }
|
31
33
|
|
32
34
|
# https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
@@ -49,13 +51,21 @@ module OmniAuth
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def raw_info
|
52
|
-
# http://
|
54
|
+
# http://vk.com/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
|
53
55
|
fields = ['uid', 'first_name', 'last_name', 'nickname', 'sex', 'city', 'country', 'online', 'bdate', 'photo', 'photo_big', 'domain']
|
54
|
-
|
56
|
+
|
57
|
+
@raw_info ||= begin
|
58
|
+
params = {
|
59
|
+
:uid => uid,
|
60
|
+
:fields => fields.join(','),
|
61
|
+
:access_token => access_token.token
|
62
|
+
}
|
63
|
+
result = access_token.get('/method/getProfiles', :params => params).parsed["response"].first
|
64
|
+
end
|
55
65
|
end
|
56
66
|
|
57
67
|
##
|
58
|
-
# You can pass +display+or +scope+ params to the auth request, if
|
68
|
+
# You can pass +display+ or +scope+ params to the auth request, if
|
59
69
|
# you need to set them dynamically.
|
60
70
|
#
|
61
71
|
# /auth/vkontakte?display=popup
|
@@ -76,20 +86,28 @@ module OmniAuth
|
|
76
86
|
|
77
87
|
private
|
78
88
|
|
79
|
-
# http://
|
89
|
+
# http://vk.com/developers.php?o=-17680044&p=getCountries
|
80
90
|
def get_country
|
81
91
|
if raw_info['country'] && raw_info['country'] != "0"
|
82
|
-
|
92
|
+
params = {
|
93
|
+
:cids => raw_info['country'],
|
94
|
+
:access_token => access_token.token
|
95
|
+
}
|
96
|
+
country = access_token.get('/method/getCountries', :params => params).parsed['response']
|
83
97
|
return country.first ? country.first['name'] : ''
|
84
98
|
else
|
85
99
|
return ''
|
86
100
|
end
|
87
101
|
end
|
88
102
|
|
89
|
-
# http://
|
103
|
+
# http://vk.com/developers.php?o=-17680044&p=getCities
|
90
104
|
def get_city
|
91
105
|
if raw_info['city'] && raw_info['city'] != "0"
|
92
|
-
|
106
|
+
params = {
|
107
|
+
:cids => raw_info['city'],
|
108
|
+
:access_token => access_token.token
|
109
|
+
}
|
110
|
+
city = access_token.get('/method/getCities', :params => params).parsed['response']
|
93
111
|
return city.first ? city.first['name'] : ''
|
94
112
|
else
|
95
113
|
return ''
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-vkontakte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|