Class: YandexTracker::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_tracker/auth.rb

Overview

Handles OAuth authentication flow and token management

Constant Summary collapse

AUTH_URL =
"https://oauth.yandex.ru/token"

Class Method Summary collapse

Class Method Details

.exchange_code(code) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/yandex_tracker/auth.rb', line 14

def exchange_code(code)
  raise ArgumentError, "code is required" if code.nil? || code.empty?

  response = make_request(grant_type: "authorization_code", code: code)
  update_configuration(response)
  response
end

.refresh_tokenObject

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
# File 'lib/yandex_tracker/auth.rb', line 22

def refresh_token
  validate_oauth_config!
  refresh_token = YandexTracker.configuration.refresh_token
  raise ArgumentError, "refresh_token is required" if refresh_token.nil? || refresh_token.empty?

  response = make_request(grant_type: "refresh_token", refresh_token: refresh_token)
  update_configuration(response)
  response
end