Repository: octokit/oauth-app.js (ts)

Issue:
the stateless methods do not set basic auth
**What happened?**

```ts
import { createToken, checkToken } from "@octokit/oauth-app";

const result = await checkToken({
  clientId: process.env.CLIENT_ID,
  clientSecret: process.env.CLIENT_SECRET,
  token
});
```

This throws a 404 error, the `authorization` header is not set

**What did you expect to happen?**

The `authorization` header should be set to basic auth from the `clientId` and `clientSecret` options

**What the problem might be**

The stateless `checkToken` method does not set any auth

https://github.com/octokit/oauth-app.js/blob/b281913f359a8dd765564fdeb8786b0f7b4b30f3/src/methods/check-token.ts#L15-L28

Pull request:
fix: add basic authentication to check token request
closes #3

Patch:
diff --git a/package.json b/package.json
index 4f8b55b..7f1a0fb 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,8 @@
     "@octokit/auth-oauth-app": "^3.0.0",
     "@octokit/core": "^2.4.1",
     "@octokit/oauth-authorization-url": "^4.0.0",
+    "@types/btoa-lite": "^1.0.0",
+    "btoa-lite": "^1.0.0",
     "fromentries": "^1.2.0",
     "universal-user-agent": "^4.0.0"
   },
diff --git a/src/methods/check-token.ts b/src/methods/check-token.ts
index d4e11df..7bc010b 100644
--- a/src/methods/check-token.ts
+++ b/src/methods/check-token.ts
@@ -1,4 +1,5 @@
 import { request as defaultRequest } from "@octokit/request";
+import btoa from "btoa-lite";
 
 import { State } from "../types";
 
@@ -12,32 +13,42 @@ type StateOptions = {
   token: string;
 };
 
+type CheckTokenRequestOptions = {
+  client_id: string;
+  access_token: string;
+};
+
 async function sendCheckTokenRequest(
   request: typeof defaultRequest,
-  options: Options
+  options: CheckTokenRequestOptions
 ) {
-  const { data } = await request("POST /applications/:client_id/token", {
-    client_id: options.clientId,
-    access_token: options.token
-  });
+  const { data } = await request(
+    "POST /applications/:client_id/token",
+    options
+  );
   return data;
 }
 
 export async function checkToken(options: Options) {
-  return sendCheckTokenRequest(defaultRequest, options);
+  const request = defaultRequest.defaults({
+    headers: {
+      authorization: `basic ${btoa(
+        `${options.clientId}:${options.clientSecret}`
+      )}`
+    }
+  });
+
+  return sendCheckTokenRequest(request, {
+    client_id: options.clientId,
+    access_token: options.token
+  });
 }
 
 export function checkTokenWithState(state: State, options: StateOptions) {
-  return sendCheckTokenRequest(
-    state.octokit.request,
-    Object.assign(
-      {
-        clientId: state.clientId,
-        clientSecret: state.clientSecret
-      },
-      options
-    )
-  );
+  return sendCheckTokenRequest(state.octokit.request, {
+    client_id: state.clientId,
+    access_token: options.token
+  });
 }
 
 export type AppCheckToken = (
diff --git a/src/methods/create-token.ts b/src/methods/create-token.ts
index aafcdf9..a427d4a 100644
--- a/src/methods/create-token.ts
+++ b/src/methods/create-token.ts
@@ -18,7 +18,7 @@ type StateOptions = {
 type Auth = ReturnType<typeof createOAuthAppAuth>;
 
 async function createTokenWithAuth(auth: Auth, options: StateOptions) {
-  // @ts-ignore fix return value for state.octokit.auth()
+  // @ts-ignore fix return types for auth()
   const { token, scopes } = await auth({
     type: "token",
     state: options.state,
diff --git a/src/methods/delete-token.ts b/src/methods/delete-token.ts
index 3de7d5c..e24d25e 100644
--- a/src/methods/delete-token.ts
+++ b/src/methods/delete-token.ts
@@ -1,5 +1,5 @@
-import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
 import { request as defaultRequest } from "@octokit/request";
+import btoa from "btoa-lite";
 
 import { emitEvent } from "../emit-event";
 import { State } from "../types";
@@ -32,11 +32,10 @@ async function sendDeleteTokenRequest(
 
 export function deleteToken(options: Options) {
   const request = defaultRequest.defaults({
-    request: {
-      hook: createOAuthAppAuth({
-        clientId: options.clientId,
-        clientSecret: options.clientSecret
-      }).hook
+    headers: {
+      authorization: `basic ${btoa(
+        `${options.clientId}:${options.clientSecret}`
+      )}`
     }
   });
 
diff --git a/src/methods/reset-token.ts b/src/methods/reset-token.ts
index 6796043..d6b2e28 100644
--- a/src/methods/reset-token.ts
+++ b/src/methods/reset-token.ts
@@ -1,5 +1,5 @@
-import { createOAuthAppAuth } from "@octokit/auth-oauth-app";
 import { request as defaultRequest } from "@octokit/request";
+import btoa from "btoa-lite";
 
 import { emitEvent } from "../emit-event";
 import { State } from "../types";
@@ -32,11 +32,10 @@ async function sendResetTokenRequest(
 
 export function resetToken(options: Options) {
   const request = defaultRequest.defaults({
-    request: {
-      hook: createOAuthAppAuth({
-        clientId: options.clientId,
-        clientSecret: options.clientSecret
-      }).hook
+    headers: {
+      authorization: `basic ${btoa(
+        `${options.clientId}:${options.clientSecret}`
+      )}`
     }
   });
 


Test patch:
diff --git a/test/methods.test.ts b/test/methods.test.ts
index 93fe0ac..fa3963b 100644
--- a/test/methods.test.ts
+++ b/test/methods.test.ts
@@ -12,10 +12,6 @@ import {
 nock.disableNetConnect();
 
 describe("app", () => {
-  it("getAuthorizationUrl", () => {
-    expect(getAuthorizationUrl).toBeInstanceOf(Function);
-  });
-
   it("getAuthorizationUrl(options)", () => {
     const url = getAuthorizationUrl({
       clientId: "0123",
@@ -26,10 +22,6 @@ describe("app", () => {
     );
   });
 
-  it("createToken", () => {
-    expect(createToken).toBeInstanceOf(Function);
-  });
-
   it("createToken(options)", async () => {
     nock("https://github.com")
       .post("/login/oauth/access_token")
@@ -50,12 +42,12 @@ describe("app", () => {
     expect(scopes).toEqual(["repo", "gist"]);
   });
 
-  it("checkToken", () => {
-    expect(checkToken).toBeInstanceOf(Function);
-  });
-
   it("checkToken(options)", async () => {
-    nock("https://api.github.com")
+    nock("https://api.github.com", {
+      reqheaders: {
+        authorization: "basic MDEyMzowMTIzc2VjcmV0"
+      }
+    })
       .post("/applications/0123/token", {
         access_token: "token123"
       })
@@ -70,12 +62,12 @@ describe("app", () => {
     expect(result).toStrictEqual({ ok: true });
   });
 
-  it("resetToken", () => {
-    expect(resetToken).toBeInstanceOf(Function);
-  });
-
   it("resetToken(options)", async () => {
-    nock("https://api.github.com")
+    nock("https://api.github.com", {
+      reqheaders: {
+        authorization: "basic MDEyMzowMTIzc2VjcmV0"
+      }
+    })
       .patch("/applications/0123/token", {
         access_token: "token123"
       })
@@ -90,12 +82,12 @@ describe("app", () => {
     expect(result).toStrictEqual({ ok: true });
   });
 
-  it("deleteToken", () => {
-    expect(deleteToken).toBeInstanceOf(Function);
-  });
-
   it("deleteToken(options)", async () => {
-    nock("https://api.github.com")
+    nock("https://api.github.com", {
+      reqheaders: {
+        authorization: "basic MDEyMzowMTIzc2VjcmV0"
+      }
+    })
       .delete("/applications/0123/token", {
         access_token: "token123"
       })
@@ -108,10 +100,6 @@ describe("app", () => {
     });
   });
 
-  it("deleteAuthorization", () => {
-    expect(deleteAuthorization).toBeInstanceOf(Function);
-  });
-
   it("deleteAuthorization(options)", async () => {
     nock("https://api.github.com")
       .delete("/applications/0123/grant", {