class Michael::Services::Github::Token
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/michael/services/github/token.rb, line 11 def initialize(config) raise Michael::Error, 'config is nil' if config.nil? @config = config end
Public Instance Methods
store(token)
click to toggle source
# File lib/michael/services/github/token.rb, line 21 def store(token) config.set(:token, value: token) end
token()
click to toggle source
# File lib/michael/services/github/token.rb, line 25 def token config.fetch(:token) end
validate(token)
click to toggle source
# File lib/michael/services/github/token.rb, line 17 def validate(token) raise Michael::Error, 'access token must contain `repo` scope' unless scopes(token).include?('repo') end
Private Instance Methods
scopes(token)
click to toggle source
# File lib/michael/services/github/token.rb, line 33 def scopes(token) Octokit::Client.new(access_token: token).scopes rescue Octokit::Unauthorized raise Michael::Error, 'invalid access token' end