Class: OmniAuth::Strategies::Nk
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Nk
- Defined in:
- lib/omniauth/strategies/nk.rb
Constant Summary collapse
- DEFAULT_RESPONSE_TYPE =
'code'
- DEFAULT_GRANT =
'authorization_code'
- DEFAULT_SCOPE =
'BASIC_PROFILE_ROLE,EMAIL_PROFILE_ROLE'
Instance Method Summary collapse
Instance Method Details
#authorize_params ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/omniauth/strategies/nk.rb', line 28 def super.tap do |params| params[:scope] ||= DEFAULT_SCOPE params[:response_type] ||= DEFAULT_RESPONSE_TYPE params[:client_id] = client.id end end |
#callback_phase ⇒ Object
21 22 23 24 25 26 |
# File 'lib/omniauth/strategies/nk.rb', line 21 def callback_phase if request.params['error'] || request.params['error_description'] fail!(request.params['error'], CallbackError.new(request.params['error'], request.params['error_description'], request.params['error_uri'])) end super end |
#raw_info ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/omniauth/strategies/nk.rb', line 65 def raw_info if @raw_info.nil? # OAuth is used to get user data fields = %w(id name emails age gender currentLocation thumbnailUrl) request_url = "http://opensocial.nk-net.pl/v09/social/rest/people/@me?fields=#{fields.join(',')}&nk_token=#{credentials['token']}" consumer = OAuth::Consumer.new(.client_id, .client_secret, {:site => 'http://opensocial.nk-net.pl'}) @raw_info = MultiJson.decode(OAuth::AccessToken.new(consumer, credentials['token']).get(request_url).body.to_s) end @raw_info end |
#token_params ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/omniauth/strategies/nk.rb', line 36 def token_params super.tap do |params| params[:scope] ||= DEFAULT_SCOPE params[:grant_type] ||= DEFAULT_GRANT params[:client_id] = client.id params[:client_secret] = client.secret end end |