Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2: Add Figma refresh token #256

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/providers/figma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { OAuth2Tokens } from "../oauth2.js";

const authorizationEndpoint = "https://www.figma.com/oauth";
const tokenEndpoint = "https://www.figma.com/api/oauth/token";
const refreshEndpoint = "https://api.figma.com/v1/oauth/refresh";

export class Figma {
private client: OAuth2Client;
Expand All @@ -21,4 +22,9 @@ export class Figma {
const tokens = await this.client.validateAuthorizationCode(tokenEndpoint, code, null);
return tokens;
}

public async refreshAccessToken(refreshToken: string): Promise<OAuth2Tokens> {
const tokens = await this.client.refreshAccessToken(refreshEndpoint, refreshToken, []);
return tokens;
}
}