Integrating Akarso in your website
You can integrate Akarso in your website adding a button to your dashboard and redirecting to the Akarso Admin Portal when the user clicks the button.
Install the akarso npm package
js
npm i akarsoRedirect the customer to the Akarso Admin Portal
When the user wants to connect SSO, redirect him to the Akarso Admin Portal
js
import { createAkarsoAdminPortalSession } from 'akarso'
// IMPORTANT: this code must run on the server
const { url } = await createAkarsoAdminPortalSession({
// TODO: replace with your own url
callbackUrl: `https://example.com/api/sso-callback`,
identifier: teamId, // your team entity identifier
// TODO use env var instead
secret: 'REPLACE_ME_SECRET', // your akarso secret
})
redirect(url)
Customer gets redirected to callbackUrl
In your callback page, connect the SSO provider to your team entity
js
import { getAkarsoCallbackResult } from 'akarso'
app.get('/api/sso-callback', async (req, res) => {
const { token } = req.query
const { identifier, ssoProviderId, domain } = await getAkarsoCallbackResult(
{
token,
secret: 'REPLACE_ME_SECRET',
},
)
// connect SSO provider to the team entity
await prisma.team.update({
where: { teamId: identifier },
data: { ssoProviderId, ssoDomain: domain },
})
// redirect user back to dashboard
res.redirect(`/team/${identifier}`)
})
Login
Users can now sign in with SSO
js
supabase.auth.signInWithSSO({
domain: 'example.com',
})
You can see a full example application written in Next.js here