Skip to content

Commit

Permalink
fix: Astro client example fix callback.ts (#79)
Browse files Browse the repository at this point in the history
The current example gives an error in v0.2.0 and up.
Updated to work again
  • Loading branch information
mvanleest authored Dec 15, 2024
1 parent 80238de commit af046fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/client/astro/src/pages/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export const GET: APIRoute = async (ctx) => {
const code = ctx.url.searchParams.get("code")
try {
const tokens = await client.exchange(code!, ctx.url.origin + "/callback")
setTokens(ctx, tokens.access, tokens.refresh)
if (!tokens.err) {
setTokens(ctx, tokens.tokens.access, tokens.tokens.refresh)
} else {
throw tokens.err
}
return ctx.redirect("/", 302)
} catch (e) {
return Response.json(e, {
Expand Down

0 comments on commit af046fa

Please sign in to comment.