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

Function EndpointNeedsScopes

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

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