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

Issue:
`app.getUserOctokit()` and `octokit.request("GET /user")` does not trigger `"token"` event
**What happened?**

Given I have this code

```js
app.on("token", async () => console.log("token event emitted"))
```

Using `app.getUserOctokit()` and `octokit.request("GET /user")` will not trigger the `"token"` event

```js
const octokit = await app.getUserOctokit({ code });

const { data } = await octokit.request("GET /user");
```

But `app.createToken()` does, as expected.

```js
app.createToken({ code });
```

**What did you expect to happen?**

The first request (`octokit.request("GET /user")`) should have triggered the `"token"` event, as the code exchange happened at this point.

**What the problem might be**

I'm not sure. The first step would be to create a test to replicate the problem


Pull request:
fix: `app.getUserOctokit()` and `octokit.request("GET /user")` does not trigger `"token"` event
fixes #220


Patch:
diff --git a/package-lock.json b/package-lock.json
index cae140e..c4893ac 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2120,9 +2120,9 @@
       }
     },
     "@octokit/auth-oauth-user": {
-      "version": "1.2.4",
-      "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-1.2.4.tgz",
-      "integrity": "sha512-efOajupCZBP1veqx5w59Qey0lIud1rDUgxTRjjkQDU3eOBmkAasY1pXemDsQwW0I85jb1P/gn2dMejedVxf9kw==",
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-1.3.0.tgz",
+      "integrity": "sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ==",
       "requires": {
         "@octokit/auth-oauth-device": "^3.1.1",
         "@octokit/oauth-methods": "^1.1.0",
@@ -10746,8 +10746,8 @@
             "binary-extensions": "^2.2.0",
             "diff": "^5.0.0",
             "minimatch": "^3.0.4",
-            "npm-package-arg": "^8.1.4",
-            "pacote": "^11.3.4",
+            "npm-package-arg": "^8.1.1",
+            "pacote": "^11.3.0",
             "tar": "^6.1.0"
           }
         },
diff --git a/package.json b/package.json
index c728501..da8f331 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
   "license": "MIT",
   "dependencies": {
     "@octokit/auth-oauth-app": "^4.0.0",
-    "@octokit/auth-oauth-user": "^1.2.3",
+    "@octokit/auth-oauth-user": "^1.3.0",
     "@octokit/auth-unauthenticated": "^2.0.0",
     "@octokit/core": "^3.3.2",
     "@octokit/oauth-authorization-url": "^4.2.1",
diff --git a/src/methods/get-user-octokit.ts b/src/methods/get-user-octokit.ts
index 6e46194..84f5aa9 100644
--- a/src/methods/get-user-octokit.ts
+++ b/src/methods/get-user-octokit.ts
@@ -7,9 +7,11 @@ import {
   GitHubAppStrategyOptionsDeviceFlow,
   GitHubAppStrategyOptionsExistingAuthentication,
   GitHubAppStrategyOptionsExistingAuthenticationWithExpiration,
+  OAuthAppAuthentication,
 } from "@octokit/auth-oauth-user";
 
 import { State, OctokitInstance, ClientType } from "../types";
+import { emitEvent } from "../emit-event";
 
 type StateOptions = "clientType" | "clientId" | "clientSecret" | "request";
 
@@ -33,11 +35,26 @@ export async function getUserOctokitWithState(
   return state.octokit.auth({
     type: "oauth-user",
     ...options,
-    factory(options: any) {
-      return new state.Octokit({
+    async factory(options: any) {
+      const octokit = new state.Octokit({
         authStrategy: createOAuthUserAuth,
         auth: options,
       });
+
+      const authentication = (await octokit.auth({
+        type: "get",
+      })) as OAuthAppAuthentication;
+
+      await emitEvent(state, {
+        name: "token",
+        action: "created",
+        token: authentication.token,
+        scopes: authentication.scopes,
+        authentication,
+        octokit,
+      });
+
+      return octokit;
     },
   }) as Promise<OctokitInstance>;
 }


Test patch:
diff --git a/test/app.test.ts b/test/app.test.ts
index a275027..a0df1b3 100644
--- a/test/app.test.ts
+++ b/test/app.test.ts
@@ -4,7 +4,7 @@ import { Octokit } from "@octokit/core";
 import { OAuthApp } from "../src";
 import { OAuthAppOctokit } from "../src/oauth-app-octokit";
 
-describe("OAuthApp.defaultst", () => {
+describe("OAuthApp.defaults", () => {
   test("sets default options", () => {
     const MyOAuthApp = OAuthApp.defaults({
       allowSignup: false,
@@ -71,6 +71,9 @@ describe("app", () => {
       Octokit: Mocktokit,
     });
 
+    const onTokenSpy = jest.fn();
+    app.on("token", onTokenSpy);
+
     const octokit = await app.getUserOctokit({
       code: "code123",
     });
@@ -80,6 +83,8 @@ describe("app", () => {
       data: { login },
     } = await octokit.request("GET /user");
     expect(login).toEqual("octocat");
+
+    expect(onTokenSpy).toHaveBeenCalled();
   });
 
   it("app.getWebFlowAuthorizationUrl(options)", () => {