Figma
Get your Credentials
- Sign in to your Figma account and go to the Developer Apps page
- Click "Create new app"
- Fill out the app details (name, description, etc.)
- Configure your redirect URI (e.g.,
https://yourdomain.com/api/auth/callback/figma) - Note your Client ID and Client Secret
The default scope is current_user:read. For additional scopes like file_content:read, refer to the Figma OAuth scopes documentation.
Make sure to set the redirect URI to match your application's callback URL. If you change the base path of the auth routes, you should update the redirect URI accordingly.
Configure the provider
To configure the provider, you need to import the provider and pass it to the social_providers option of the auth instance.
require "better_auth"
auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
social_providers: {
figma: BetterAuth::SocialProviders.figma(
client_id: ENV.fetch("FIGMA_CLIENT_ID"),
client_secret: ENV.fetch("FIGMA_CLIENT_SECRET")
)
}
)Sign In with Figma
To sign in with Figma, call auth.api.sign_in_social on your Ruby auth instance. The endpoint body takes the following properties:
provider: The provider to use. It should be set tofigma.
response = auth.api.sign_in_social(
body: {
provider: "figma",
callback_url: "/dashboard",
error_callback_url: "/login",
disable_redirect: true
}
)
redirect_url = response.fetch(:url)For more information about Figma's OAuth scopes and API capabilities, refer to the official Figma API documentation.