egovSso.generateAccessToken with the partner code, partner secret, and exchange code. Pass the returned bearer token to egovSso.authenticate through auth.12345import { createClient } from "egov.js"; const client = createClient({ baseUrl: "https://hackathon-sso.e.gov.ph", });
egovSso.generateAccessTokenPOST /api/token exchanges the partner code, partner secret, and citizen authorization code for an access token.123456789101112import { 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.authenticatePOST /api/partner/sso_authentication uses the bearer token to return the authenticated citizen profile.1234567import { egovSso } from "egov.js"; const citizen = await egovSso.authenticate({ client, auth: token.access_token, throwOnError: true, });