Skip to content

Commit

Permalink
add :display option, which you pass in to the provider method
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Mar 4, 2012
1 parent f6b3960 commit e563cdf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on the [Vkontakte Developers Page](http://vk.com/developers.php).
## Basic Usage

use OmniAuth::Builder do
provider :vkontakte, ENV['API_KEY'], ENV['API_SECRET']
provider :vkontakte, ENV['API_KEY'], ENV['API_SECRET'], :scope => 'friends,audio', :display => 'popup'
end

## Ruby
Expand All @@ -19,7 +19,7 @@ Tested with the following Ruby versions:

## License

Copyright (c) 2011 Anton Maminov.
Copyright (c) 2011, 2012 Anton Maminov.

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:

Expand Down
2 changes: 1 addition & 1 deletion examples/sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Rack::Session::Cookie

use OmniAuth::Builder do
provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'], :scope => SCOPE
provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'], :scope => SCOPE, :display => 'popup'
end

get '/' do
Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth-vkontakte/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module OmniAuth
module Vkontakte
VERSION = "1.0.5"
VERSION = "1.0.6"
end
end
12 changes: 11 additions & 1 deletion lib/omniauth/strategies/vkontakte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Strategies
# @example Basic Usage
# use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
class Vkontakte < OmniAuth::Strategies::OAuth2
DEFAULT_SCOPE = ''
DEFAULT_SCOPE = 'friends,audio'

option :name, 'vkontakte'

Expand All @@ -25,6 +25,8 @@ class Vkontakte < OmniAuth::Strategies::OAuth2
:param_name => 'access_token',
}

option :authorize_options, [:scope, :display]

uid { access_token.params['user_id'] }

# https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
Expand Down Expand Up @@ -52,8 +54,16 @@ def raw_info
@raw_info ||= access_token.get('/method/getProfiles', :params => { :uid => uid, :fields => fields.join(',') }).parsed["response"].first
end

##
# You can pass +display+or +scope+ params to the auth request, if
# you need to set them dynamically.
#
# /auth/vkontakte?display=popup
#
def authorize_params
super.tap do |params|
params.merge!(:display => request.params['display']) if request.params['display']
params.merge!(:scope => request.params['scope']) if request.params['scope']
params[:scope] ||= DEFAULT_SCOPE
end
end
Expand Down

0 comments on commit e563cdf

Please sign in to comment.