Actually support :mobile and :sign_in options for Foursquare strategy.
This commit is contained in:
parent
dfa11efc8a
commit
b124e599dc
|
@ -9,13 +9,18 @@ module OmniAuth
|
|||
# @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow.
|
||||
# @option options [Boolean, false] :mobile When true, use the mobile sign-in interface.
|
||||
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
||||
options[:sign_in] ||= true
|
||||
super(app, :foursquare, client_id, client_secret, {
|
||||
:site => "https://api.foursquare.com/v2",
|
||||
:authorize_url => "https://foursquare.com/oauth2/authenticate",
|
||||
:authorize_url => authorize_url(options),
|
||||
:access_token_url => "https://foursquare.com/oauth2/access_token"
|
||||
}, options, &block)
|
||||
end
|
||||
|
||||
def authorize_url(options)
|
||||
"https://foursquare.com/#{'mobile/' if options[:mobile]}oauth2/#{options[:sign_in] ? 'authenticate' : 'authorize'}"
|
||||
end
|
||||
|
||||
def user_data
|
||||
@data ||= MultiJson.decode(@access_token.get(client.site+'/users/self', {'oauth_token' => @access_token.token}))
|
||||
end
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe OmniAuth::Strategies::Foursquare do
|
||||
it_should_behave_like "an oauth2 strategy"
|
||||
subject{ OmniAuth::Strategies::Foursquare.new(lambda{|env|[200,{},[""]]} , 'abc', 'def')}
|
||||
|
||||
it 'should use the mobile authorize url when :mobile is true' do
|
||||
subject.authorize_url(:mobile => true).should be_include("/mobile/")
|
||||
end
|
||||
|
||||
it 'should use the authorize endpoint if :sign_in is false' do
|
||||
subject.authorize_url(:sign_in => false).should be_include("/authorize")
|
||||
end
|
||||
|
||||
it 'should default to the authenticate endpoint' do
|
||||
subject.client.authorize_url.should be_include('/authenticate')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue