MCPcopy
hub / github.com/cli/cli / EndpointNeedsScopes

Function EndpointNeedsScopes

api/client.go:202–207  ·  view source on GitHub ↗

EndpointNeedsScopes adds additional OAuth scopes to an HTTP response as if they were returned from the server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the OAuth scopes they need.

(resp *http.Response, s string)

Source from the content-addressed store, hash-verified

200// server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the
201// OAuth scopes they need.
202func EndpointNeedsScopes(resp *http.Response, s string) {
203 if resp.StatusCode >= 400 && resp.StatusCode < 500 {
204 oldScopes := resp.Header.Get("X-Accepted-Oauth-Scopes")
205 resp.Header.Set("X-Accepted-Oauth-Scopes", fmt.Sprintf("%s, %s", oldScopes, s))
206 }
207}
208
209func generateScopesSuggestion(statusCode int, endpointNeedsScopes, tokenHasScopes, hostname string) string {
210 if statusCode < 400 || statusCode > 499 || statusCode == 422 {

Callers 2

createGistFunction · 0.92
deleteRepoFunction · 0.92

Calls 2

GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected