Skip to content

Commit

Permalink
fix token refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
devkiran committed Oct 23, 2024
1 parent 955ce50 commit 53808cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/api/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function oauthCallbackServer({
const configInfo: DubConfig = {
access_token: accessToken.trim(),
refresh_token: refreshToken,
expires_at: expiresAt ? Date.now() + expiresAt * 1000 : null,
expires_at: expiresAt,
domain: "dub.sh",
};

Expand Down
13 changes: 6 additions & 7 deletions packages/cli/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export async function getConfig(): Promise<DubConfig> {
const config = configStore.all as DubConfig;

if (config.expires_at && Date.now() >= config.expires_at) {
const response = await oauthClient.refreshToken({
accessToken: config.access_token,
refreshToken: config.refresh_token,
expiresAt: config.expires_at,
});

const { accessToken, refreshToken, expiresAt } = response;
const { accessToken, refreshToken, expiresAt } =
await oauthClient.refreshToken({
accessToken: config.access_token,
refreshToken: config.refresh_token,
expiresAt: config.expires_at,
});

return await setConfig({
access_token: accessToken,
Expand Down

0 comments on commit 53808cb

Please sign in to comment.