Sha256: 3f9b127433c25560061f4b4cef4d29b62435d3431f747f30788d9dc0fac737f9

Contents?: true

Size: 555 Bytes

Versions: 3

Compression:

Stored size: 555 Bytes

Contents

require 'faraday'

require_relative 'token'
require_relative '../globals'

module Spaceship
  class TokenRefreshMiddleware < Faraday::Middleware
    def initialize(app, token)
      @token = token
      super(app)
    end

    def call(env)
      if @token.expired?
        puts("App Store Connect API token expired at #{@token.expiration}... refreshing") if Spaceship::Globals.verbose?
        @token.refresh!
      end

      env.request_headers["Authorization"] = "Bearer #{@token.text}"

      @app.call(env)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fastlane_hotfix-2.165.1 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane_hotfix-2.165.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane_hotfix-2.187.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb