Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Use eGov SSO

eGov SSO exchanges partner credentials and a citizen authorization code for an access token, then returns the authenticated citizen profile.
SSO responses contain personally identifiable information. Keep partner secrets, tokens, and citizen profiles on trusted server infrastructure.

Authentication flow

Call egovSso.generateAccessToken with the partner code, partner secret, and exchange code. Pass the returned bearer token to egovSso.authenticate through auth.

Initialize the client

Create a dedicated client for the documented eGov SSO hackathon host:
import { createClient } from "egov.js"; const client = createClient({ baseUrl: "https://hackathon-sso.e.gov.ph", });

Methods

The examples below use this eGov SSO client. See the quickstart for the general client pattern.
The API Reference tab documents token-exchange errors, bearer authentication, request fields, and the citizen profile schema.

egovSso.generateAccessToken

POST /api/token exchanges the partner code, partner secret, and citizen authorization code for an access token.
import { egovSso } from "egov.js"; const token = await egovSso.generateAccessToken({ client, body: { exchange_code: authorizationCode, partner_code: process.env.EGOVSSO_PARTNER_CODE!, partner_secret: process.env.EGOVSSO_PARTNER_SECRET!, scope: "SSO_AUTHENTICATION", }, throwOnError: true, });

egovSso.authenticate

POST /api/partner/sso_authentication uses the bearer token to return the authenticated citizen profile.
import { egovSso } from "egov.js"; const citizen = await egovSso.authenticate({ client, auth: token.access_token, throwOnError: true, });