9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/issue_db/authentication.rb', line 9
def self.login(client = nil, log = nil)
unless client.nil?
log.debug("using pre-provided client") if log
return client
end
if ENV.fetch("ISSUE_DB_GITHUB_APP_ID", nil) && ENV.fetch("ISSUE_DB_GITHUB_APP_INSTALLATION_ID", nil) && ENV.fetch("ISSUE_DB_GITHUB_APP_KEY", nil)
log.debug("using github app authentication") if log
return GitHubApp.new
end
token = ENV.fetch("ISSUE_DB_GITHUB_TOKEN", nil)
if token
log.debug("using github token authentication") if log
octokit = Octokit::Client.new(access_token: token, page_size: 100)
octokit.auto_paginate = true
return octokit
end
raise AuthenticationError, "No valid GitHub authentication method was provided"
end
|