Skip to content

Commit

Permalink
fix oauth guide
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Dec 12, 2023
1 parent fb80624 commit fe05bab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/pages/guides/oauth/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ app.get("/login/github/callback", async (request: Request): Promise<Response> =>

try {
const tokens = await githubAuth.validateAuthorizationCode(code);
const githubUser = await githubAuth.getUser(tokens.accessToken);
const githubUserResponse = await fetch("https://api.github.com/user", {
headers: {
Authorization: `Bearer ${tokens.accessToken}`
}
});
const githubUserResult: GitHubUserResult = await githubUserResponse.json();

const existingUser = await db.table("user").where("github_id", "=", githubUser.id).get();

Expand Down Expand Up @@ -171,4 +176,9 @@ app.get("/login/github/callback", async (request: Request): Promise<Response> =>
});
}
});

interface GitHubUserResult {
id: number;
login: string; // username
}
```

0 comments on commit fe05bab

Please sign in to comment.