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

Function EndpointNeedsScopes

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

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