Exception: Octokit::OneTimePasswordRequired

Inherits:
ClientError show all
Defined in:
lib/octokit/error.rb

Overview

Raised when GitHub returns a 401 HTTP status code and headers include “X-GitHub-OTP”

Constant Summary collapse

OTP_DELIVERY_PATTERN =
/required; (\w+)/i.freeze

Instance Attribute Summary

Attributes inherited from Error

#context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#build_error_context, #documentation_url, error_for_401, error_for_403, error_for_404, error_for_422, #errors, from_response, #initialize, #response_body, #response_headers, #response_status

Constructor Details

This class inherits a constructor from Octokit::Error

Class Method Details

.required_header(headers) ⇒ Object



244
245
246
# File 'lib/octokit/error.rb', line 244

def self.required_header(headers)
  OTP_DELIVERY_PATTERN.match headers['X-GitHub-OTP'].to_s
end

Instance Method Details

#password_deliveryString

Delivery method for the user’s OTP

Returns:

  • (String)


251
252
253
# File 'lib/octokit/error.rb', line 251

def password_delivery
  @password_delivery ||= delivery_method_from_header
end