omniauth-douban-oauth2 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -3,6 +3,12 @@
3
3
  This is the 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
4
 
5
5
 
6
+ ## How to install
7
+
8
+ ``` ruby
9
+ gem install omniauth-douban-oauth2
10
+ ```
11
+
6
12
  ## Basic Usage
7
13
 
8
14
  ``` ruby
@@ -11,12 +17,73 @@ use OmniAuth::Builder do
11
17
  end
12
18
  ```
13
19
 
14
- ## How to install
20
+ ## Example with Sinatra
15
21
 
16
22
  ``` ruby
17
- gem install omniauth-douban-oauth2
23
+ require 'sinatra'
24
+ require 'omniauth-douban-oauth2'
25
+
26
+ KEY = 'your api key'
27
+ SECRET = 'your api secret'
28
+
29
+ use Rack::Session::Cookie
30
+
31
+ use OmniAuth::Builder do
32
+ provider :douban, KEY, SECRET
33
+ end
34
+
35
+ get '/' do
36
+ '<a href="/auth/douban">Douban</a>'
37
+ end
38
+
39
+ get '/auth/douban/callback' do
40
+ auth = env['omniauth.auth']
41
+ auth.to_hash.to_s
42
+ end
43
+
44
+ get '/auth/failure' do
45
+ 'auth failure'
46
+ end
47
+
18
48
  ```
19
49
 
20
- ## Wiki
50
+ ## Auth Hash
21
51
 
22
- [Wiki](https://github.com/liluo/omniauth-douban-oauth2/wiki)
52
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
53
+
54
+ ```ruby
55
+ {
56
+ "provider" => "douban",
57
+ "uid" => "2217855",
58
+ "info" => {
59
+ "uid" => "xiaosong",
60
+ "name" => "小松其实还没有",
61
+ "loc_id" => "118371",
62
+ "loc_name" => "陕西西安",
63
+ "avatar" => "http://img3.douban.com/icon/u2217855-34.jpg",
64
+ "alt" => "http://www.douban.com/people/xiaosong/",
65
+ "desc" => "你确实知道就必须证明",
66
+ "created" => "2008-02-05 15:26:44"
67
+ },
68
+ "credentials" => {
69
+ "token" => "6516f0d........", # OAuth 2.0 access_token
70
+ "refresh_token" => "30c8c560..........", # OAuth 2.0 refresh_token
71
+ "expires_at" => 1357053699, # when the access token expires (it always will)
72
+ "expires" => true # this will always be true
73
+ },
74
+ "extra" => {
75
+ "raw_info" => {
76
+ "loc_id" => "118371",
77
+ "name" => "小松其实还没有",
78
+ "created" => "2008-02-05 15:26:44",
79
+ "loc_name" => "陕西西安",
80
+ "avatar" => "http://img3.douban.com/icon/u2217855-34.jpg",
81
+ "signature" => "啊我要增肥...",
82
+ "uid" => "xiaosong",
83
+ "alt" => "http://www.douban.com/people/xiaosong/",
84
+ "id" => "2217855",
85
+ "desc" => "你确实知道就必须证明"
86
+ }
87
+ }
88
+ }
89
+ ```
@@ -21,14 +21,12 @@ module OmniAuth
21
21
 
22
22
  info do
23
23
  {
24
- :uid => raw_info['uid'],
25
24
  :name => raw_info['name'],
26
- :loc_id => raw_info['loc_id'],
27
- :loc_name => raw_info['loc_name'],
28
- :avatar => raw_info['avatar'],
29
- :alt => raw_info['alt'],
30
- :desc => raw_info['desc'],
31
- :created => raw_info['created'],
25
+ :nickname => raw_info['uid'],
26
+ :location => raw_info['loc_name'],
27
+ :image => raw_info['avatar'],
28
+ :urls => {:alt => raw_info['alt']},
29
+ :description => raw_info['desc'],
32
30
  }
33
31
  end
34
32
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Douban
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-douban-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-09-07 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth