-
Auth Server URL:
https://auth.civic.com/oauth/ - Client ID: Provided on sign-up at auth.civic.com
-
Scopes:
openid email profile
The Civic Auth Server
At its core, Civic Auth is an OAuth 2.0 auth server. It supports the authorization code grant type with PKCE.If you are looking for other OAuth 2 grant types, we’d like to hear from you in our developer community.
Sample Call to the OAuth Server
To trigger a login process, simply call the oauth server as follows:Query Parameters:
-
client_id: Your application’s unique identifier provided by Civic Auth. -
redirect_uri: The URL to which users should be redirected after authentication. -
scope: The permissions your application is requesting (e.g.,openid email profile). Scopes must be space-separated as per OAuth 2.0 RFC6749 specification. -
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 the
code_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 WebAPISample code
Sample code
index.html
Refreshing a session
The Civic OAuth server supports the token refresh flow by calling the oauth server as follows:Query Parameters:
-
client_id: Your application’s unique identifier provided by Civic Auth. -
refresh_token: The refresh token from the user’s existing session -
grant_type: a string ‘refresh_token’
Usage
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:This example uses browser-compatible JWT decoding. The
jsonwebtoken library is designed for Node.js and won’t work in browser environments. For production applications, consider using a dedicated browser JWT library like jwt-decode.
