Sha256: e3dfbbc574da2262d7baad6a2b309829278000238149d875f569ec4c351e417d

Contents?: true

Size: 531 Bytes

Versions: 103

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

103 entries across 103 versions & 4 rubygems

Version Path
fastlane-2.226.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.225.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.224.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.223.1 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.223.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.222.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.221.1 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.221.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.220.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.219.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.218.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-security-patched-2.216.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.217.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.216.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.215.1 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.215.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-mercafacil-2.214.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.214.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.213.0 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb
fastlane-2.212.2 spaceship/lib/spaceship/connect_api/token_refresh_middleware.rb