omniauth-stackexchange 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/README.md +3 -1
- data/lib/omniauth-stackexchange/version.rb +1 -1
- data/lib/omniauth/strategies/stackexchange.rb +15 -4
- metadata +9 -8
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## 0.1.0 (July 11, 2012) ##
|
2
|
+
|
3
|
+
### enhancements
|
4
|
+
* Add ability to specify site option to uniquely identify the StackExchange site (by [@ginnyd](https://github.com/ginnyd))
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
provider :stackexchange, "client_id", "client_secret", public_key: "key", site: 'stackoverflow'
|
8
|
+
```
|
data/README.md
CHANGED
@@ -22,12 +22,14 @@ Once these are in, you need to add the following to your `config/initializers/om
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
25
|
-
provider :stackexchange, "client_id", "client_secret", public_key: "key"
|
25
|
+
provider :stackexchange, "client_id", "client_secret", public_key: "key", site: 'stackoverflow'
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
29
29
|
You will obviously have to put in your client_id, client_secret and public_key, which you get when you register your app with StackExchange (they call them Client Id, Client Secret and Key).
|
30
30
|
|
31
|
+
You will also need to specify a site option to uniquely identify the StackExchange site (e.g. `stackoverflow` or `superuser`) you wish to authenticate against. A list of valid site api keys can be found at https://api.stackexchange.com/docs/sites. It's `stackoverflow` by default.
|
32
|
+
|
31
33
|
Now just follow the README at: https://github.com/intridea/omniauth
|
32
34
|
|
33
35
|
## Supported Rubies
|
@@ -3,6 +3,8 @@ require 'omniauth-oauth2'
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
5
|
class StackExchange < OmniAuth::Strategies::OAuth2
|
6
|
+
class NotRegisteredForStackExchangeSiteError < StandardError; end
|
7
|
+
|
6
8
|
option :client_options, {
|
7
9
|
:site => 'https://api.stackexchange.com/2.0',
|
8
10
|
:authorize_url => 'https://stackexchange.com/oauth',
|
@@ -24,9 +26,8 @@ module OmniAuth
|
|
24
26
|
'nickname' => raw_info['display_name'],
|
25
27
|
'image' => raw_info['profile_image'],
|
26
28
|
'urls' => {
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
site => raw_info['link']
|
30
|
+
}
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
@@ -36,15 +37,25 @@ module OmniAuth
|
|
36
37
|
|
37
38
|
def raw_info
|
38
39
|
@raw_info ||= access_token.get('me', :params => params).parsed['items'].first
|
40
|
+
|
41
|
+
unless @raw_info
|
42
|
+
raise NotRegisteredForStackExchangeSiteError, "User is not registered for requested StackExchange site (#{site})"
|
43
|
+
end
|
44
|
+
|
45
|
+
@raw_info
|
39
46
|
end
|
40
47
|
|
41
48
|
def params
|
42
49
|
{
|
43
|
-
:site =>
|
50
|
+
:site => site,
|
44
51
|
:access_token => access_token.token,
|
45
52
|
:key => options.public_key
|
46
53
|
}
|
47
54
|
end
|
55
|
+
|
56
|
+
def site
|
57
|
+
options.site || 'stackoverflow'
|
58
|
+
end
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-stackexchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &26976260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *26976260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: omniauth-oauth2
|
27
|
-
requirement: &
|
27
|
+
requirement: &26975740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '1.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *26975740
|
36
36
|
description: StackExchange OAuth strategy for OmniAuth
|
37
37
|
email:
|
38
38
|
- younash@gmail.com
|
@@ -42,6 +42,7 @@ extra_rdoc_files: []
|
|
42
42
|
files:
|
43
43
|
- .gitignore
|
44
44
|
- .travis.yml
|
45
|
+
- CHANGELOG.md
|
45
46
|
- Gemfile
|
46
47
|
- LICENSE
|
47
48
|
- README.md
|
@@ -66,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
67
|
version: '0'
|
67
68
|
segments:
|
68
69
|
- 0
|
69
|
-
hash:
|
70
|
+
hash: -3679528809500990391
|
70
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
72
|
none: false
|
72
73
|
requirements:
|
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
76
|
version: '0'
|
76
77
|
segments:
|
77
78
|
- 0
|
78
|
-
hash:
|
79
|
+
hash: -3679528809500990391
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
82
|
rubygems_version: 1.8.10
|