MCPcopy Index your code
hub / github.com/apache/devlake / PrepareApiClient

Method PrepareApiClient

backend/plugins/github/models/connection.go:77–96  ·  view source on GitHub ↗

PrepareApiClient splits Token to tokens for SetupAuthentication to utilize

(apiClient plugin.ApiClient)

Source from the content-addressed store, hash-verified

75
76// PrepareApiClient splits Token to tokens for SetupAuthentication to utilize
77func (conn *GithubConn) PrepareApiClient(apiClient plugin.ApiClient) errors.Error {
78
79 if conn.AuthMethod == AccessToken {
80 conn.tokens = strings.Split(conn.Token, ",")
81 }
82
83 if conn.AuthMethod == AppKey && conn.InstallationID != 0 {
84 token, err := conn.GetInstallationAccessToken(apiClient)
85 if err != nil {
86 return err
87 }
88 var expiresAt *time.Time
89 if !token.ExpiresAt.IsZero() {
90 expiresAt = &token.ExpiresAt
91 }
92 conn.UpdateToken(token.Token, "", expiresAt, nil)
93 }
94
95 return nil
96}
97
98// SetupAuthentication sets up the HTTP Request Authentication
99func (conn *GithubConn) SetupAuthentication(req *http.Request) errors.Error {

Callers

nothing calls this directly

Calls 2

UpdateTokenMethod · 0.95

Tested by

no test coverage detected