MCPcopy Create free account
hub / github.com/google/go-github / getOAuthAppClient

Function getOAuthAppClient

test/integration/authorizations_test.go:127–150  ·  view source on GitHub ↗

getOAuthAppClient returns a GitHub client for authorization testing. The client uses BasicAuth, but instead of username and password, it uses the client id and client secret passed in via environment variables (and will skip the calling test if those vars are not present). Certain API operations (ch

(t *testing.T)

Source from the content-addressed store, hash-verified

125//
126// See GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
127func getOAuthAppClient(t *testing.T) *github.Client {
128 t.Helper()
129
130 username, ok := os.LookupEnv(envKeyClientID)
131 if !ok {
132 t.Skipf(msgEnvMissing, envKeyClientID)
133 }
134
135 password, ok := os.LookupEnv(envKeyClientSecret)
136 if !ok {
137 t.Skipf(msgEnvMissing, envKeyClientSecret)
138 }
139
140 tp := github.BasicAuthTransport{
141 Username: strings.TrimSpace(username),
142 Password: strings.TrimSpace(password),
143 }
144
145 c, err := github.NewClient(github.WithHTTPClient(tp.Client()))
146 if err != nil {
147 t.Fatal(err)
148 }
149 return c
150}

Callers 1

Calls 3

ClientMethod · 0.95
NewClientFunction · 0.92
WithHTTPClientFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…