* Make an authenticated request to the client's endpoint with its token. * Used for GitHub API requests.
(
method: HTTPMethod,
path: string,
options: {
body?: Object
customHeaders?: Object
reloadCache?: boolean
} = {}
)
| 1824 | * Used for GitHub API requests. |
| 1825 | */ |
| 1826 | private async ghRequest( |
| 1827 | method: HTTPMethod, |
| 1828 | path: string, |
| 1829 | options: { |
| 1830 | body?: Object |
| 1831 | customHeaders?: Object |
| 1832 | reloadCache?: boolean |
| 1833 | } = {} |
| 1834 | ): Promise<Response> { |
| 1835 | const response = await this.request(this.endpoint, method, path, options) |
| 1836 | |
| 1837 | // Only consider invalid token when the status is 401 and the response has |
| 1838 | // the X-GitHub-Request-Id header, meaning it comes from GH(E) and not from |
| 1839 | // any kind of proxy/gateway. For more info see #12943 |
| 1840 | // We're also not considering a token has been invalidated when the reason |
| 1841 | // behind a 401 is the fact that any kind of 2 factor auth is required. |
| 1842 | if ( |
| 1843 | response.status === HttpStatusCode.Unauthorized && |
| 1844 | response.headers.has('X-GitHub-Request-Id') && |
| 1845 | !response.headers.has('X-GitHub-OTP') |
| 1846 | ) { |
| 1847 | API.emitTokenInvalidated(this.endpoint, this.token) |
| 1848 | } |
| 1849 | |
| 1850 | tryUpdateEndpointVersionFromResponse(this.endpoint, response) |
| 1851 | |
| 1852 | return response |
| 1853 | } |
| 1854 | |
| 1855 | /** |
| 1856 | * Make an authenticated request to the client's Copilot endpoint with its |
no test coverage detected