Skip to content

Commit 4aca7b6

Browse files
authored
Merge pull request #84 from DazWorrall/query-auth-deprecated
Use header auth mode for user and email requests
2 parents 2e77639 + f367321 commit 4aca7b6

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

lib/omniauth/strategies/github.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def authorize_params
4343
end
4444

4545
def raw_info
46-
access_token.options[:mode] = :query
46+
access_token.options[:mode] = :header
4747
@raw_info ||= access_token.get('user').parsed
4848
end
4949

@@ -59,7 +59,7 @@ def primary_email
5959
# The new /user/emails API - http://developer.github.com/v3/users/emails/#future-response
6060
def emails
6161
return [] unless email_access_allowed?
62-
access_token.options[:mode] = :query
62+
access_token.options[:mode] = :header
6363
@emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed
6464
end
6565

spec/omniauth/strategies/github_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@
122122
expect(access_token).to receive(:get).with('user').and_return(response)
123123
expect(subject.raw_info).to eq(parsed_response)
124124
end
125+
126+
it 'should use the header auth mode' do
127+
expect(access_token).to receive(:get).with('user').and_return(response)
128+
subject.raw_info
129+
expect(access_token.options[:mode]).to eq(:header)
130+
end
125131
end
126132

127133
context '#emails' do
@@ -133,6 +139,16 @@
133139
subject.options['scope'] = 'user'
134140
expect(subject.emails).to eq(parsed_response)
135141
end
142+
143+
it 'should use the header auth mode' do
144+
expect(access_token).to receive(:get).with('user/emails', :headers => {
145+
'Accept' => 'application/vnd.github.v3'
146+
}).and_return(response)
147+
148+
subject.options['scope'] = 'user'
149+
subject.emails
150+
expect(access_token.options[:mode]).to eq(:header)
151+
end
136152
end
137153

138154
context '#info.email' do

0 commit comments

Comments
 (0)