MCPcopy Create free account
hub / github.com/cli/cli / EndpointNeedsScopes

Function EndpointNeedsScopes

api/client.go:354–359  ·  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

352// server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the
353// OAuth scopes they need.
354func EndpointNeedsScopes(resp *http.Response, s string) {
355 if resp.StatusCode >= 400 && resp.StatusCode < 500 {
356 oldScopes := resp.Header.Get("X-Accepted-Oauth-Scopes")
357 resp.Header.Set("X-Accepted-Oauth-Scopes", fmt.Sprintf("%s, %s", oldScopes, s))
358 }
359}
360
361func generateScopesSuggestion(statusCode int, endpointNeedsScopes, tokenHasScopes, hostname string) string {
362 if statusCode < 400 || statusCode > 499 || statusCode == 422 {

Callers 1

DoRequestMethod · 0.85

Calls 2

GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected