Class: OmniAuth::Strategies::Deezer
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Deezer
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/deezer.rb
Defined Under Namespace
Classes: CredentialsError
Constant Summary collapse
- DEFAULT_PERMS =
"basic_access"
Instance Method Summary collapse
-
#callback_phase ⇒ Object
callback phase.
- #request_phase ⇒ Object
Instance Method Details
#callback_phase ⇒ Object
callback phase
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/omniauth/strategies/deezer.rb', line 36 def callback_phase begin if request.params['error_reason'] then raise CredentialsError, request.params['error_reason'] end # get token from Deezer token_url = ..token_url+'?app_id='+.app_id+'&secret='+.app_secret+'&code='+request.params['code'] response = Faraday.get token_url response_hash = CGI::parse(response.body.chomp) @access_token = response_hash['access_token'][0] @token_expires_at = response_hash['expires'][0].to_i me_path = ..me_url+'?access_token='+@access_token # get info from current user response = Faraday.get me_path @raw_info = MultiJson.decode(response.body.chomp) super rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e) rescue TypeError => e fail!(:invalid_response, e) rescue CredentialsError => e fail!(:invalid_credentials, e) end end |
#request_phase ⇒ Object
28 29 30 31 32 |
# File 'lib/omniauth/strategies/deezer.rb', line 28 def request_phase .perms ||= DEFAULT_PERMS redirecting_to = ..+'?app_id='+.app_id+'&redirect_uri='+CGI::escape(callback_url)+'&perms='+.perms redirect redirecting_to end |