Changed the Hyves OAuth strategy to allow options to be set for the 'request
token' stage. By adding options you can customize the methods (scope) and duration of the authorization: :hyves, 'token', 'secret', :methods => 'users.get,friends.get', :expirationtype => 'infinite' More: http://www.hyves-developers.nl/documentation/data-api/methods/2.0/auth.requesttoken
This commit is contained in:
Родитель
ec6230ac9a
Коммит
a0733e8d7d
|
@ -5,13 +5,19 @@ module OmniAuth
|
||||||
module Strategies
|
module Strategies
|
||||||
class Hyves < OmniAuth::Strategies::OAuth
|
class Hyves < OmniAuth::Strategies::OAuth
|
||||||
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
|
||||||
|
options = {
|
||||||
|
:methods => 'users.get,friends.get,wwws.create',
|
||||||
|
:expirationtype => 'default'
|
||||||
|
}.merge(options)
|
||||||
|
|
||||||
client_options = {
|
client_options = {
|
||||||
:authorize_path => 'http://www.hyves.nl/api/authorize',
|
:authorize_path => 'http://www.hyves.nl/api/authorize',
|
||||||
:access_token_path => access_token_path,
|
:access_token_path => access_token_path,
|
||||||
:http_method => :get,
|
:http_method => :get,
|
||||||
:request_token_path => request_token_path,
|
:request_token_path => request_token_path(options),
|
||||||
:scheme => :header,
|
:scheme => :header,
|
||||||
}
|
}
|
||||||
|
|
||||||
super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
|
super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,8 +43,10 @@ module OmniAuth
|
||||||
rsp['user'].first
|
rsp['user'].first
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_token_path
|
def request_token_path(options)
|
||||||
"http://data.hyves-api.nl/?#{request_token_options}&#{default_options}"
|
options['ha_method'] = 'auth.requesttoken'
|
||||||
|
options['strict_oauth_spec_response'] = true
|
||||||
|
"http://data.hyves-api.nl/?#{to_params(options)}&#{default_options}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def access_token_path
|
def access_token_path
|
||||||
|
@ -49,10 +57,6 @@ module OmniAuth
|
||||||
to_params({:ha_version => '2.0', :ha_format => 'json', :ha_fancylayout => false})
|
to_params({:ha_version => '2.0', :ha_format => 'json', :ha_fancylayout => false})
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_token_options
|
|
||||||
to_params({:methods => 'users.get,friends.get,wwws.create', :ha_method => 'auth.requesttoken', :strict_oauth_spec_response => true})
|
|
||||||
end
|
|
||||||
|
|
||||||
def access_token_options
|
def access_token_options
|
||||||
to_params({:ha_method => 'auth.accesstoken', :strict_oauth_spec_response => true})
|
to_params({:ha_method => 'auth.accesstoken', :strict_oauth_spec_response => true})
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче