Skip to content

GebetaAuth

Server-side authentication for Node.js backends.

Import

ts
import { GebetaAuth } from '@gebeta/node';

Constructor

ts
new GebetaAuth(options: { serverToken: string })
ParameterTypeDescription
options.serverTokenstringYour Gebeta server token (keep secret, backend only)

Methods

authenticate(clientToken)

Exchanges a client token and server token for a short-lived access/refresh token pair.

ts
authenticate(clientToken: string): Promise<{ accessToken: string; refreshToken: string }>
ParameterTypeDescription
clientTokenstringThe public client token received from the client app

Example

ts
const auth = new GebetaAuth({ serverToken: process.env.GEBETA_SERVER_TOKEN! });

app.post('/auth', async (req, res) => {
  const credentials = await auth.authenticate(req.body.clientToken);
  res.json(credentials); // { accessToken, refreshToken }
});