omniauth-mixi 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +13 -0
- data/Guardfile +10 -0
- data/README.md +121 -0
- data/Rakefile +8 -0
- data/example/Gemfile +4 -0
- data/example/config.ru +22 -0
- data/lib/omniauth-mixi.rb +2 -0
- data/lib/omniauth-mixi/version.rb +5 -0
- data/lib/omniauth/strategies/mixi.rb +111 -0
- data/omniauth-mixi.gemspec +24 -0
- data/spec/omniauth/strategies/mixi_spec.rb +216 -0
- data/spec/spec_helper.rb +19 -0
- metadata +162 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# OmniAuth mixi
|
2
|
+
|
3
|
+
This gem contains the mixi strategy for OmniAuth.
|
4
|
+
|
5
|
+
mixi uses the OAuth2 server flow, you can read about it here: http://developer.mixi.co.jp/en/connect/mixi_graph_api/api_auth/
|
6
|
+
|
7
|
+
## How To Use It
|
8
|
+
|
9
|
+
So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth-mixi'
|
13
|
+
```
|
14
|
+
(11/26/2012) This is not registered to Rubygems yet.
|
15
|
+
|
16
|
+
You can also pull them in directly from Github e.g.:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'omniauth-mixi', git => 'https://github.com/mixi-inc/omniauth-mixi.git'
|
20
|
+
```
|
21
|
+
|
22
|
+
Then `bundle install` to install dependencies.
|
23
|
+
|
24
|
+
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :mixi, 'consumer_key', 'consumer_secret'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
You will obviously have to put in your key and secret, which you get when you register your app with Partner Dashboard.
|
33
|
+
|
34
|
+
When you define like the Builder above, you will retrieve basic user's informations. If you want to retrieve minimum information set only, the parameter `:info_level` can be used:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
38
|
+
provider :mixi, 'consumer_key', 'consumer_secret', :info_level => :min
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Now just follow the README at: https://github.com/intridea/omniauth
|
43
|
+
|
44
|
+
## Auth Hash
|
45
|
+
|
46
|
+
Here's an example Auth Hash available in `request.env['omniauth.auth']`:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
{
|
50
|
+
:provider => 'mixi',
|
51
|
+
:uid => '1234567',
|
52
|
+
:info => {
|
53
|
+
:name => 'Yoichiro Tanaka',
|
54
|
+
:first_name => 'Yoichiro',
|
55
|
+
:last_name => 'Tanaka',
|
56
|
+
:description => 'I am an engineer. And, ...',
|
57
|
+
:location => 'Hasuda-shi, Saitama pref.',
|
58
|
+
:nickname => 'Yoichiro',
|
59
|
+
:urls => {
|
60
|
+
:profile => 'http://mixi.jp/show_friend.pl?uid=1234567'
|
61
|
+
},
|
62
|
+
:image => 'https://profile.img.mixi.jp/1234567.jpg'
|
63
|
+
},
|
64
|
+
credentials => {
|
65
|
+
:token => 'ABCDEFG...', # OAuth 2.0 access_token, which you may wish to store
|
66
|
+
:refresh_token => 'HIJKLMN...',
|
67
|
+
:expires_at => 1353854879, # when the access token expires (it always will)
|
68
|
+
:expires => true
|
69
|
+
},
|
70
|
+
:extra => {
|
71
|
+
:raw_info => {
|
72
|
+
:addresses => [{
|
73
|
+
:region => 'Saitama pref.',
|
74
|
+
:type => 'location',
|
75
|
+
:locality => 'Hasuda-shi'
|
76
|
+
}],
|
77
|
+
:thumbnailUrl => 'https://profile.img.mixi.jp/1234567.jpg',
|
78
|
+
:aboutMe => 'I am an engineer. And, ...',
|
79
|
+
:name => {
|
80
|
+
:givenName => 'Yoichiro',
|
81
|
+
:familyName => 'Tanaka'
|
82
|
+
},
|
83
|
+
:id => '1234567',
|
84
|
+
:profileUrl => 'http://mixi.jp/show_friend.pl?uid=1234567',
|
85
|
+
:displayName => 'Yoichiro'
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
```
|
90
|
+
|
91
|
+
The precise information available may depend on the permissions which you request.
|
92
|
+
|
93
|
+
## How To Launch Example
|
94
|
+
|
95
|
+
This project includes an example application to try OmniAuth-mixi quickly. You can launch the example by the following commands:
|
96
|
+
|
97
|
+
$ cd example
|
98
|
+
$ bundle install
|
99
|
+
$ CLIENT_ID=[consumer_key] CLIENT_SECRET=[consumer_secret] rackup
|
100
|
+
|
101
|
+
Of course, you have to replace the two parameters `[consumer_key]` and `[consumer_secret]` to them issued for your application.
|
102
|
+
|
103
|
+
And, open http://localhost:9292/ in your browser, then you will see the authentication and authorization page of mixi.
|
104
|
+
|
105
|
+
## Supported Rubies
|
106
|
+
|
107
|
+
OmniAuth mixi is tested under 1.8.7, 1.9.2, 1.9.3 and JRuby.
|
108
|
+
|
109
|
+
[![CI Build
|
110
|
+
Status](https://secure.travis-ci.org/mixi-inc/omniauth-mixi.png)](http://travis-ci.org/mixi-inc/omniauth-mixi)
|
111
|
+
[![Dependency Status](https://gemnasium.com/mixi-inc/omniauth-mixi.png)](https://gemnasium.com/mixi-inc/omniauth-mixi)
|
112
|
+
|
113
|
+
## License
|
114
|
+
|
115
|
+
Copyright (c) 2012 by mixi, Inc. and Yoichiro Tanaka
|
116
|
+
|
117
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
118
|
+
|
119
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
120
|
+
|
121
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'omniauth-mixi'
|
4
|
+
|
5
|
+
class App < Sinatra::Base
|
6
|
+
get '/' do
|
7
|
+
redirect '/auth/mixi'
|
8
|
+
end
|
9
|
+
|
10
|
+
get '/auth/:provider/callback' do
|
11
|
+
content_type 'application/json'
|
12
|
+
MultiJson.encode(request.env)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
use Rack::Session::Cookie
|
17
|
+
|
18
|
+
use OmniAuth::Builder do
|
19
|
+
provider :mixi, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
|
20
|
+
end
|
21
|
+
|
22
|
+
run App.new
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Mixi < OmniAuth::Strategies::OAuth2
|
6
|
+
MINIMUM_SCOPE = 'r_profile'
|
7
|
+
BASIC_SCOPE = ([MINIMUM_SCOPE] + ['name',
|
8
|
+
'location',
|
9
|
+
'about_me'].map {|scope|
|
10
|
+
"#{MINIMUM_SCOPE}_#{scope}"
|
11
|
+
}).join(' ')
|
12
|
+
|
13
|
+
option :client_options, {
|
14
|
+
:site => 'https://api.mixi-platform.com',
|
15
|
+
:authorize_url => 'https://mixi.jp/connect_authorize.pl',
|
16
|
+
:token_url => 'https://api.mixi-platform.com/2/token'
|
17
|
+
}
|
18
|
+
|
19
|
+
option :authorize_options, [:scope, :display]
|
20
|
+
|
21
|
+
uid do
|
22
|
+
raw_info['id']
|
23
|
+
end
|
24
|
+
|
25
|
+
info do
|
26
|
+
prune!({
|
27
|
+
'name' => real_name[:name],
|
28
|
+
'first_name' => real_name[:first_name],
|
29
|
+
'last_name' => real_name[:last_name],
|
30
|
+
'description' => raw_info['aboutMe'],
|
31
|
+
'location' => location,
|
32
|
+
'nickname' => raw_info['displayName'],
|
33
|
+
'urls' => {
|
34
|
+
'profile' => raw_info['profileUrl']
|
35
|
+
},
|
36
|
+
'image' => raw_info['thumbnailUrl']
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
extra do
|
41
|
+
hash = {}
|
42
|
+
hash['raw_info'] = raw_info unless skip_info?
|
43
|
+
prune!(hash)
|
44
|
+
end
|
45
|
+
|
46
|
+
def raw_info
|
47
|
+
access_token.options[:mode] = :header
|
48
|
+
@raw_info ||=
|
49
|
+
access_token.get('/2/people/@me/@self?fields=@all').parsed['entry']
|
50
|
+
end
|
51
|
+
|
52
|
+
def authorize_params
|
53
|
+
super.tap do |params|
|
54
|
+
%w[display state scope].each do |v|
|
55
|
+
if request.params[v]
|
56
|
+
params[v.to_sym] = request.params[v]
|
57
|
+
session['omniauth.state'] = params[:state] if v == 'state'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
unless params[:scope]
|
61
|
+
if options[:info_level] == :min
|
62
|
+
params[:scope] = MINIMUM_SCOPE
|
63
|
+
else
|
64
|
+
params[:scope] = BASIC_SCOPE
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def prune!(hash)
|
73
|
+
hash.delete_if do |_, value|
|
74
|
+
prune!(value) if value.is_a?(Hash)
|
75
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def real_name
|
80
|
+
name = raw_info['name']
|
81
|
+
if name
|
82
|
+
{
|
83
|
+
:name => "#{name['familyName']} #{name['givenName']}",
|
84
|
+
:first_name => name['givenName'],
|
85
|
+
:last_name => name['familyName']
|
86
|
+
}
|
87
|
+
else
|
88
|
+
{
|
89
|
+
:name => raw_info['displayName'],
|
90
|
+
:first_name => nil,
|
91
|
+
:last_name => nil
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def location
|
97
|
+
prefecture = nil
|
98
|
+
addresses = raw_info['addresses']
|
99
|
+
if addresses
|
100
|
+
addresses.each do |address|
|
101
|
+
prefecture = "#{address['region']}#{address['locality']}"
|
102
|
+
break if address['type'] == 'location'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
prefecture
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
OmniAuth.config.add_camelization 'mixi', 'Mixi'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-mixi/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Yoichiro Tanaka"]
|
6
|
+
gem.email = ["yoichiro@eisbahn.jp"]
|
7
|
+
gem.description = %q{OmniAuth strategy for mixi.}
|
8
|
+
gem.summary = %q{OmniAuth strategy for mixi.}
|
9
|
+
gem.homepage = "https://github.com/mixi-inc/omniauth-mixi"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "omniauth-mixi"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OmniAuth::Mixi::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
19
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
21
|
+
gem.add_development_dependency 'rack-test'
|
22
|
+
gem.add_development_dependency 'simplecov'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
PEOPLE_API = '/2/people/@me/@self?fields=@all'
|
4
|
+
|
5
|
+
describe OmniAuth::Strategies::Mixi do
|
6
|
+
subject do
|
7
|
+
OmniAuth::Strategies::Mixi.new({})
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'Client options' do
|
11
|
+
before(:all) do
|
12
|
+
@options = subject.options.client_options
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have correct site' do
|
16
|
+
@options.site.should == 'https://api.mixi-platform.com'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have correct authorize url' do
|
20
|
+
@options.authorize_url.should == 'https://mixi.jp/connect_authorize.pl'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have correct token url' do
|
24
|
+
@options.token_url.should == 'https://api.mixi-platform.com/2/token'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'Authorize params' do
|
29
|
+
it 'should include the MINIMUM_SCOPE if info_level is min' do
|
30
|
+
request = stub('Request')
|
31
|
+
request.stub!(:params).and_return({})
|
32
|
+
args = [nil, nil, {:info_level => :min}]
|
33
|
+
target = OmniAuth::Strategies::Mixi.new(nil, *args).tap do |strategy|
|
34
|
+
strategy.stub!(:request).and_return(request)
|
35
|
+
strategy.stub!(:session).and_return({})
|
36
|
+
end
|
37
|
+
target.authorize_params[:scope].should == 'r_profile'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should include the BASIC_SCOPE if info_level is not specified' do
|
41
|
+
request = stub('Request')
|
42
|
+
request.stub!(:params).and_return({})
|
43
|
+
args = [nil, nil, {}]
|
44
|
+
target = OmniAuth::Strategies::Mixi.new(nil, *args).tap do |strategy|
|
45
|
+
strategy.stub!(:request).and_return(request)
|
46
|
+
strategy.stub!(:session).and_return({})
|
47
|
+
end
|
48
|
+
target.authorize_params[:scope].should ==
|
49
|
+
'r_profile r_profile_name r_profile_location r_profile_about_me'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should include the special :scope parameter' do
|
53
|
+
request = stub('Request')
|
54
|
+
request.stub!(:params).and_return({})
|
55
|
+
args = [nil, nil, {:scope => 'r_profile r_voice'}]
|
56
|
+
target = OmniAuth::Strategies::Mixi.new(nil, *args).tap do |strategy|
|
57
|
+
strategy.stub!(:request).and_return(request)
|
58
|
+
strategy.stub!(:session).and_return({})
|
59
|
+
end
|
60
|
+
target.authorize_params[:scope].should == 'r_profile r_voice'
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should include the display parameter' do
|
64
|
+
request = stub('Request')
|
65
|
+
request.stub!(:params).and_return({})
|
66
|
+
args = [nil, nil, {:display => 'touch'}]
|
67
|
+
target = OmniAuth::Strategies::Mixi.new(nil, *args).tap do |strategy|
|
68
|
+
strategy.stub!(:request).and_return(request)
|
69
|
+
strategy.stub!(:session).and_return({})
|
70
|
+
end
|
71
|
+
target.authorize_params[:display].should == 'touch'
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should include the display parameter via request' do
|
75
|
+
request = stub('Request')
|
76
|
+
request.stub!(:params).and_return({'display' => 'touch'})
|
77
|
+
args = [nil, nil, {}]
|
78
|
+
target = OmniAuth::Strategies::Mixi.new(nil, *args).tap do |strategy|
|
79
|
+
strategy.stub!(:request).and_return(request)
|
80
|
+
strategy.stub!(:session).and_return({})
|
81
|
+
end
|
82
|
+
target.authorize_params[:display].should == 'touch'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'User info' do
|
87
|
+
before do
|
88
|
+
options = mock('options')
|
89
|
+
options.should_receive('[]=').exactly(8)
|
90
|
+
access_token = mock('access_token')
|
91
|
+
access_token.should_receive(:options).exactly(8).and_return(options)
|
92
|
+
api_result = mock('api_result')
|
93
|
+
api_result.should_receive(:parsed).and_return(parsed_entry)
|
94
|
+
access_token.should_receive(:get).with(PEOPLE_API).and_return(api_result)
|
95
|
+
subject.access_token = access_token
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should have correct info' do
|
99
|
+
user_info = subject.info
|
100
|
+
user_info['nickname'].should == 'displayName1'
|
101
|
+
user_info['name'].should == 'familyName1 givenName1'
|
102
|
+
user_info['first_name'].should == 'givenName1'
|
103
|
+
user_info['last_name'].should == 'familyName1'
|
104
|
+
user_info['description'].should == 'aboutMe1'
|
105
|
+
user_info['location'].should == 'region1locality1'
|
106
|
+
user_info['urls'].should_not be_nil
|
107
|
+
user_info['urls']['profile'].should == 'profileUrl1'
|
108
|
+
user_info['image'].should == 'thumbnailUrl1'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'User info without name' do
|
113
|
+
before do
|
114
|
+
options = mock('options')
|
115
|
+
options.should_receive('[]=').exactly(11)
|
116
|
+
access_token = mock('access_token')
|
117
|
+
access_token.should_receive(:options).exactly(11).and_return(options)
|
118
|
+
api_result = mock('api_result')
|
119
|
+
api_result.should_receive(:parsed).and_return(parsed_entry_without_name)
|
120
|
+
access_token.should_receive(:get).with(PEOPLE_API).and_return(api_result)
|
121
|
+
subject.access_token = access_token
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should have correct info' do
|
125
|
+
user_info = subject.info
|
126
|
+
user_info['nickname'].should == 'displayName1'
|
127
|
+
user_info['name'].should == 'displayName1'
|
128
|
+
user_info['first_name'].should be_nil
|
129
|
+
user_info['last_name'].should be_nil
|
130
|
+
user_info['description'].should == 'aboutMe1'
|
131
|
+
user_info['location'].should == 'region1locality1'
|
132
|
+
user_info['urls'].should_not be_nil
|
133
|
+
user_info['urls']['profile'].should == 'profileUrl1'
|
134
|
+
user_info['image'].should == 'thumbnailUrl1'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'User ID' do
|
139
|
+
before do
|
140
|
+
options = mock('options')
|
141
|
+
options.should_receive('[]=')
|
142
|
+
access_token = mock('access_token')
|
143
|
+
access_token.should_receive(:options).and_return(options)
|
144
|
+
parsed = {'entry' => {
|
145
|
+
'id' => 'id1'
|
146
|
+
}
|
147
|
+
}
|
148
|
+
api_result = mock('api_result')
|
149
|
+
api_result.should_receive(:parsed).and_return(parsed)
|
150
|
+
access_token.should_receive(:get).with(PEOPLE_API).and_return(api_result)
|
151
|
+
subject.access_token = access_token
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should have correct uid' do
|
155
|
+
subject.uid.should == 'id1'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe 'Extra info' do
|
160
|
+
before do
|
161
|
+
options = mock('options')
|
162
|
+
options.should_receive('[]=').exactly(1)
|
163
|
+
access_token = mock('access_token')
|
164
|
+
access_token.should_receive(:options).exactly(1).and_return(options)
|
165
|
+
api_result = mock('api_result')
|
166
|
+
api_result.should_receive(:parsed).and_return(parsed_entry)
|
167
|
+
access_token.should_receive(:get).with(PEOPLE_API).and_return(api_result)
|
168
|
+
subject.access_token = access_token
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should have correct extra' do
|
172
|
+
extra_info = subject.extra['raw_info']
|
173
|
+
extra_info.should_not be_nil
|
174
|
+
extra_info['id'].should == 'id1'
|
175
|
+
extra_info['displayName'].should == 'displayName1'
|
176
|
+
extra_info['name'].should_not be_nil
|
177
|
+
extra_info['name']['givenName'].should == 'givenName1'
|
178
|
+
extra_info['name']['familyName'].should == 'familyName1'
|
179
|
+
extra_info['aboutMe'].should == 'aboutMe1'
|
180
|
+
extra_info['addresses'].should_not be_nil
|
181
|
+
extra_info['addresses'].should have(1).items
|
182
|
+
extra_info['addresses'][0]['region'].should == 'region1'
|
183
|
+
extra_info['addresses'][0]['type'].should == 'location'
|
184
|
+
extra_info['addresses'][0]['locality'].should == 'locality1'
|
185
|
+
extra_info['profileUrl'].should == 'profileUrl1'
|
186
|
+
extra_info['thumbnailUrl'].should == 'thumbnailUrl1'
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def parsed_entry
|
192
|
+
{
|
193
|
+
'entry' => {
|
194
|
+
'id' => 'id1',
|
195
|
+
'displayName' => 'displayName1',
|
196
|
+
'name' => {
|
197
|
+
'givenName' => 'givenName1',
|
198
|
+
'familyName' => 'familyName1'
|
199
|
+
},
|
200
|
+
'aboutMe' => 'aboutMe1',
|
201
|
+
'addresses' => [{
|
202
|
+
'region' => 'region1',
|
203
|
+
'type' => 'location',
|
204
|
+
'locality' => 'locality1'
|
205
|
+
}],
|
206
|
+
'profileUrl' => 'profileUrl1',
|
207
|
+
'thumbnailUrl' => 'thumbnailUrl1'
|
208
|
+
}
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def parsed_entry_without_name
|
213
|
+
hash = parsed_entry
|
214
|
+
hash['entry'].delete('name')
|
215
|
+
hash
|
216
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
require 'rack/test'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
|
11
|
+
require 'omniauth'
|
12
|
+
require 'omniauth-mixi'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include WebMock::API
|
16
|
+
config.include Rack::Test::Methods
|
17
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-mixi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yoichiro Tanaka
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: omniauth-oauth2
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.1'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.1'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rack-test
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: webmock
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: OmniAuth strategy for mixi.
|
111
|
+
email:
|
112
|
+
- yoichiro@eisbahn.jp
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- Guardfile
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- example/Gemfile
|
125
|
+
- example/config.ru
|
126
|
+
- lib/omniauth-mixi.rb
|
127
|
+
- lib/omniauth-mixi/version.rb
|
128
|
+
- lib/omniauth/strategies/mixi.rb
|
129
|
+
- omniauth-mixi.gemspec
|
130
|
+
- spec/omniauth/strategies/mixi_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/mixi-inc/omniauth-mixi
|
133
|
+
licenses: []
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
hash: 304646765529695186
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
hash: 304646765529695186
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 1.8.24
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: OmniAuth strategy for mixi.
|
162
|
+
test_files: []
|