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)
| 200 | // server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the |
| 201 | // OAuth scopes they need. |
| 202 | func 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 | |
| 209 | func generateScopesSuggestion(statusCode int, endpointNeedsScopes, tokenHasScopes, hostname string) string { |
| 210 | if statusCode < 400 || statusCode > 499 || statusCode == 422 { |
no test coverage detected