hpyhacking/peatio · error · APIv2::OutOfScopeError

2011

2011

Error message

Requested API is out of access key scopes.

What it means

Error "Requested API is out of access key scopes." thrown in hpyhacking/peatio.

Source

Thrown at app/api/api_v2/auth/authenticator.rb:25

        @params  = params
      end

      def authenticate!
        check_token!
        check_tonce!
        check_signature!
        token
      end

      def token
        @token ||= APIToken.joins(:member).where(access_key: @params[:access_key]).first
      end

      def check_token!
        raise InvalidAccessKeyError, @params[:access_key] unless token
        raise DisabledAccessKeyError, @params[:access_key] if token.member.api_disabled
        raise ExpiredAccessKeyError, @params[:access_key] if token.expired?
        raise OutOfScopeError unless token.in_scopes?(route_scopes)
      end

      def check_signature!
        if @params[:signature] != Utils.hmac_signature(token.secret_key, payload)
          Rails.logger.warn "APIv2 auth failed: signature doesn't match. token: #{token.access_key} payload: #{payload}"
          raise IncorrectSignatureError, @params[:signature]
        end
      end

      def check_tonce!
        key = "api_v2:tonce:#{token.access_key}:#{tonce}"
        if Utils.cache.read(key)
          Rails.logger.warn "APIv2 auth failed: used tonce. token: #{token.access_key} payload: #{payload} tonce: #{tonce}"
          raise TonceUsedError.new(token.access_key, tonce)
        end
        Utils.cache.write key, tonce, 61 # forget after 61 seconds

        now = Time.now.to_i*1000

View on GitHub (pinned to dab8641137)

Solutions

  1. Add the scope that covers the requested API to the access key, or call the API with a key that already has the required scope.

When it happens

Trigger: Thrown at app/api/api_v2/auth/authenticator.rb:25 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hpyhacking/peatio@dab8641137 (2026-08-23). Data as JSON: /api/errors/0a7d90fc2aea763f. Report an issue: GitHub.