Class: OmniAuth::Strategies::Shapeways

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/shapeways.rb

Instance Method Summary collapse

Instance Method Details

#raw_infoObject



54
55
56
# File 'lib/omniauth/strategies/shapeways.rb', line 54

def raw_info
  @raw_info ||= MultiJson.decode(access_token.get('/api/v1/').body)
end

#request_phaseObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omniauth/strategies/shapeways.rb', line 18

def request_phase
  request_token = consumer.get_request_token(:oauth_callback => callback_url)
  
  # Shapeways seems to have a way of providing the token that does not play nicely with the underlying oauth gem.
  # I think that normally the token is provided in the body instead of as a query string parameter.
  # As a result, we need parse it out of the query string provided by Shapeways:
  q = Rack::Utils.parse_query URI(request_token.params['authentication_url']).query
  request_token.token = q['oauth_token']
  
  session['oauth'] ||= {}
  session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => q['oauth_token'], 'request_secret' => request_token.secret}

  if request_token.callback_confirmed?
    redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_consumer_key => consumer.key))
  else
    redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url, :oauth_consumer_key => consumer.key))
  end

  rescue ::Timeout::Error => e
    fail!(:timeout, e)
  rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
    fail!(:service_unavailable, e)
end