React Native
Overview
React Native applications can integrate with Leadovaro Auth using any OAuth2/OIDC-compatible library. Popular options include:
For a complete OAuth2/OIDC integration details, see the Leadovaro 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
Leadovaro Auth uses standard OAuth2/OIDC endpoints:
- Authorization:
/_sites/auth.leadovaro.com/oauth/auth - Token:
/_sites/auth.leadovaro.com/oauth/token - UserInfo:
/_sites/auth.leadovaro.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 Leadovaro 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:
// Uses expo-auth-session for OAuth2 flow
const [request, response, promptAsync] = useAuthRequest(
{
clientId: config.clientId,
scopes: ["openid", "profile", "email"],
redirectUri: config.redirectUri,
usePKCE: true, // Required by Leadovaro Auth
},
{
authorizationEndpoint: config.authorizationEndpoint,
tokenEndpoint: config.tokenEndpoint,
},
);
// Authentication methods
const authContext = {
signIn: () => promptAsync(),
signOut: async () => {
// Clear tokens and end remote session
},
state: { isAuthenticated, user, accessToken },
};
Resources
- Leadovaro Auth OAuth2/OIDC Integration
- Complete React Native Example