Sha256: e3dfbbc574da2262d7baad6a2b309829278000238149d875f569ec4c351e417d

Contents?: true

Size: 531 Bytes

Versions: 102

Compression:

Stored size: 531 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

102 entries across 102 versions & 4 rubygems

Version Path
fastlane-2.174.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.173.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.172.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.171.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.170.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.169.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.168.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.167.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.166.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.165.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.164.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.163.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.162.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.161.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.160.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.159.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.158.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.157.4 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.157.3 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.157.2 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb