Vicinae

OAuth

Built-in support for OAuth 2.0 PKCE flows, allowing extensions to authenticate with third-party services.

Setup

Create a PKCE client with your provider details.

import { OAuth } from "@vicinae/api";

const client = new OAuth.PKCEClient({
  redirectMethod: OAuth.RedirectMethod.Web,
  providerName: "GitHub",
  providerIcon: "github.png",
  description: "Connect your GitHub account",
});

Authorization Flow

import { OAuth } from "@vicinae/api";

const client = new OAuth.PKCEClient({
  redirectMethod: OAuth.RedirectMethod.Web,
  providerName: "GitHub",
  providerIcon: "github.png",
});

const authRequest = await client.authorizationRequest({
  endpoint: "https://github.com/login/oauth/authorize",
  clientId: "your-client-id",
  scope: "repo user",
});

const { authorizationCode } = await client.authorize(authRequest);
// Exchange authorizationCode for tokens via your provider's token endpoint

Token Storage

Store and retrieve tokens.

await client.setTokens({
  accessToken: "gho_...",
  refreshToken: "ghr_...",
  expiresIn: 3600,
});

const tokens = await client.getTokens();
if (tokens?.isExpired()) {
  // refresh the token
}

Redirect Methods

MethodDescription
OAuth.RedirectMethod.WebRedirects through the Raycast website. A Vicinae equivalent will ship in the future.
OAuth.RedirectMethod.AppUses raycast:// app scheme
OAuth.RedirectMethod.AppURIUses com.raycast:/ URI scheme