Class: Faraday::Restiny::Auth

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/destiny/auth.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/faraday/destiny/auth.rb', line 11

def on_complete(env)
  return if env['response_body'].empty? || env['url'].to_s !~ /oauth/

  return unless env['response_body']['error']

  raise ::Restiny::AuthenticationError.new(
    env['response_body']['error_description'],
    env['response_body']['error']
  )
end