client_id: Your application's unique identifier provided by CivicAuth.
redirect_uri: The URL to which users should be redirected after authentication.
scope: The permissions your application is requesting (e.g., email, profile, openid).
state: A random string to maintain state between the request and callback.
code_challenge: A code challenge derived from the code verifier for PKCE.
Civic Auth requires the use of PKCE (Proof Key for Code Exchange), so thecode_challenge parameter is obligatory. For more information, see PKCE (Proof Key for Code Exchange).
Example
See below for an example of using Civic Auth with a third-party library: OAuth 4 WebAPI
The Civic Auth SDK is designed to simplify front-end integration, with optimized support for React and Next.js. However, if your frontend uses another framework, you can still retrieve user information after login by inspecting the ID token.
The ID token is produced after completing the login process. A common pattern is for your backend to pass that token to your frontend as a cookie.
Here’s an example of how to access user information in vanilla JavaScript by reading the ID token cookie:
import jwt from'jsonwebtoken';functiongetUserFromToken() {constcookie=document.cookie.split('; ').find(row =>row.startsWith('id_token='));if (!cookie) returnnull;consttoken=cookie.split('=')[1];returnjwt.decode(token);}constuser=getUserFromToken();console.log(user); // Log user info or use it in your app