Skip to content

Commit e24e1d8

Browse files
zhyd1997anikdhabalUdit-takkarvolneidhairyashiil
authored
fix(apps/web): enhance JWT response with token type and expiration details (calcom#24841)
* fix: enhance JWT response with token type and expiration details * fix: update email generation in createUsersFixture to use v4 UUID without dashes * revert: update email generation in createUsersFixture to use short-uuid for unique email identifiers --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Volnei Munhoz <volnei@cal.com> Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com>
1 parent ef4be48 commit e24e1d8

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

  • apps/web/app/api/auth/oauth/token

apps/web/app/api/auth/oauth/token/route.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,28 @@ async function handler(req: NextRequest) {
7979
clientId: client_id,
8080
};
8181

82+
const accessTokenExpiresIn = 1800; // 30 minutes
83+
8284
const access_token = jwt.sign(payloadAuthToken, secretKey, {
83-
expiresIn: 1800, // 30 min
85+
expiresIn: accessTokenExpiresIn,
8486
});
8587

8688
const refresh_token = jwt.sign(payloadRefreshToken, secretKey, {
8789
expiresIn: 30 * 24 * 60 * 60, // 30 days
8890
});
8991

90-
return NextResponse.json({ access_token, refresh_token }, { status: 200 });
92+
// @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
93+
return NextResponse.json(
94+
{ access_token, token_type: "bearer", refresh_token, expires_in: accessTokenExpiresIn },
95+
{
96+
status: 200,
97+
headers: {
98+
"Content-Type": "application/json;charset=UTF-8",
99+
"Cache-Control": "no-store",
100+
Pragma: "no-cache",
101+
},
102+
}
103+
);
91104
}
92105

93106
export const POST = defaultResponderForAppDir(handler);

0 commit comments

Comments
 (0)