Skip to content

Commit

Permalink
fix: auth.hook() uses app auth for "https://api.github.com/app/instal…
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 8, 2019
1 parent b8b5910 commit 3ed56c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getInstallationAuthentication } from "./get-installation-authentication
import { requiresAppAuth } from "./requires-app-auth";
import {
AnyResponse,
EndpointDefaults,
EndpointOptions,
RequestParameters,
RequestInterface,
Expand All @@ -17,12 +16,13 @@ export async function hook(
route: Route | EndpointOptions,
parameters?: RequestParameters
): Promise<AnyResponse> {
let endpoint: EndpointDefaults = request.endpoint.merge(
route as string,
parameters
);
let endpoint = request.endpoint.merge(route as string, parameters);

if (requiresAppAuth(endpoint.url)) {
if (
requiresAppAuth(
(endpoint.url as string).replace(request.endpoint.DEFAULTS.baseUrl, "")
)
) {
const { token } = await getAppAuthentication(state.id, state.privateKey);
endpoint.headers.authorization = `bearer ${token}`;

Expand Down

0 comments on commit 3ed56c2

Please sign in to comment.