Integration
React Native
Integrate react-native with civic-auth OAuth2 services.
Overview
React Native applications can integrate with Civic Auth using any OAuth2/OIDC-compatible library. Popular options include:
For a complete OAuth2/OIDC integration details, see the Civic Auth Integration Guide.
Reference Implementation
A complete working example is available in the civic-auth-examples repository, which demonstrates:
- OAuth2 authorization code flow with PKCE
- Login flow
- Logout flow
Implementation Approach
1. Configure OAuth2 Endpoints
Civic Auth uses standard OAuth2/OIDC endpoints:
- Authorization:
https://auth.civic.com/oauth/auth
- Token:
https://auth.civic.com/oauth/token
- UserInfo:
https://auth.civic.com/oauth/userinfo
- Scopes:
openid profile email
2. Authentication Flow
The reference implementation follows a standard OAuth2 authorization code flow with PKCE:
- User initiates sign-in
- App opens Civic Auth on a WebView
- User authenticates
- App receives authorization code through redirect
- App exchanges code for tokens
- App fetches user information
3. Example AuthContext
The reference project’s AuthContext
demonstrates how to use Expo AuthSession: