Class: Michael::Models::Github::TokenValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/michael/models/github/token_validator.rb

Class Method Summary collapse

Class Method Details

.save_token(token) ⇒ Object



23
24
25
# File 'lib/michael/models/github/token_validator.rb', line 23

def save_token(token)
  Configuration.new.set(:token, value: token)
end

.token_valid?(token) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
# File 'lib/michael/models/github/token_validator.rb', line 12

def token_valid?(token)
  scopes = Octokit::Client.new(access_token: token).scopes

  return true if scopes.include?('repo')

  puts 'Token should have `repo` scope'
  false
rescue StandardError
  false
end