Sha256: 22f1c6a8ee060a5ca6ec37c0175d428a244027c4459807ca2dea4c66455f4e67

Contents?: true

Size: 691 Bytes

Versions: 17

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

module FmRest
  module Cloud
    class AuthErrorHandler < Faraday::Middleware
      def initialize(app, settings)
        super(app)
        @settings = settings
      end

      def call(env)
        request_body = env[:body] # After failure env[:body] is set to the response body
        @app.call(env)
      rescue APIError::AccountError => e
        ClarisIdTokenManager.new(@settings).expire_token
        # Faraday::Request::Authorization will not get a new token if the
        # Authorization header is already set
        env.request_headers.delete("Authorization")
        env[:body] = request_body
        @app.call(env)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fmrest-cloud-0.26.2 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.26.1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.26.1.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.26.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.26.0.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.25.0.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.24.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.24.0.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.23.1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.23.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.22.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.21.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.21.0.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.20.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.20.0.rc1 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.19.0 lib/fmrest/cloud/auth_error_handler.rb
fmrest-cloud-0.19.0.rc1 lib/fmrest/cloud/auth_error_handler.rb