omniauth-douban-oauth2 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +12 -0
- data/README.md +12 -0
- data/lib/omniauth/strategies/douban.rb +52 -0
- data/lib/omniauth-douban/version.rb +5 -0
- data/lib/omniauth-douban-oauth2.rb +2 -0
- data/omniauth-douban-oauth2.gemspec +21 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# OmniAuth-Douban-oauth2
|
2
|
+
======================
|
3
|
+
This is the official OmniAuth strategy for authenticating to Douban. To use it, you'll need to sign up for an OAuth2 Application Key and Secret on the [Open Platform](https://www.douban.com/service/auth2/apikey/apply)
|
4
|
+
|
5
|
+
|
6
|
+
## Basic Usage
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
use OmniAuth::Builder do
|
10
|
+
provider :douban, ENV['DOUBAN_KEY'], ENV['DOUBAN_SECRET']
|
11
|
+
end
|
12
|
+
```
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Douban < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'douban'
|
7
|
+
option :client_options, {
|
8
|
+
:site => 'https://api.douban.com',
|
9
|
+
:authorize_url => 'https://www.douban.com/service/auth2/auth',
|
10
|
+
:token_url => 'https://www.douban.com/service/auth2/token'
|
11
|
+
}
|
12
|
+
|
13
|
+
option :token_params, {
|
14
|
+
:parse => :json,
|
15
|
+
}
|
16
|
+
|
17
|
+
uid do
|
18
|
+
raw_info['id']
|
19
|
+
end
|
20
|
+
|
21
|
+
info do
|
22
|
+
{
|
23
|
+
:nickname => raw_info['uid'],
|
24
|
+
:name => raw_info['screen_name'],
|
25
|
+
:city => raw_info['city'],
|
26
|
+
:location => raw_info['location'],
|
27
|
+
:description => raw_info['description'],
|
28
|
+
|
29
|
+
:douban => {
|
30
|
+
:url => raw_info['url'],
|
31
|
+
:created_at => raw_info['created_at'],
|
32
|
+
:large_avatar => raw_info['large_avatar']
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
extra do
|
38
|
+
{ :raw_info => raw_info }
|
39
|
+
end
|
40
|
+
|
41
|
+
def raw_info
|
42
|
+
access_token.options[:param_name] = 'access_token'
|
43
|
+
@raw_info ||= access_token.get('/shuo/users/@me').parsed
|
44
|
+
rescue ::Timeout::Error => e
|
45
|
+
raise e
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
OmniAuth.config.add_camelization 'douban', 'Douban'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../lib/omniauth-douban/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ['Liluo']
|
7
|
+
gem.email = ['i@liluo.org']
|
8
|
+
gem.description = %q{OmniAuth OAuth2 strategy for Douban.}
|
9
|
+
gem.summary = %q{OmniAuth OAuth2 strategy for Douban.}
|
10
|
+
gem.homepage = 'https://github.com/liluo/omniauth-douban-oauth2'
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = 'omniauth-douban-oauth2'
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
gem.version = OmniAuth::Douban::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
20
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-douban-oauth2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Liluo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: &2160197700 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2160197700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: omniauth-oauth2
|
27
|
+
requirement: &2160196920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.1'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2160196920
|
36
|
+
description: OmniAuth OAuth2 strategy for Douban.
|
37
|
+
email:
|
38
|
+
- i@liluo.org
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- lib/omniauth-douban-oauth2.rb
|
47
|
+
- lib/omniauth-douban/version.rb
|
48
|
+
- lib/omniauth/strategies/douban.rb
|
49
|
+
- omniauth-douban-oauth2.gemspec
|
50
|
+
homepage: https://github.com/liluo/omniauth-douban-oauth2
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.15
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: OmniAuth OAuth2 strategy for Douban.
|
74
|
+
test_files: []
|