@wavemaker/react-native-app-auth-expo-plugin
v1.0.0
Published
Expo plugin for react-native-app-auth to enable OAuth and OpenID Connect authentication in Expo projects
Readme
@wavemaker/react-native-app-auth-expo-plugin
Expo plugin for react-native-app-auth to enable OAuth and OpenID Connect authentication in Expo projects
Installation
npm install @wavemaker/react-native-app-auth-expo-pluginConfiguration
1. Add the plugin to your app.json/app.config.js
{
"expo": {
"plugins": [
[
"@wavemaker/react-native-app-auth-expo-plugin",
{
"redirectScheme": "com.org.myapp.auth",
"enableUniversalLinks": false
}
]
]
}
}Plugin Options
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| redirectScheme | string | ✅ | The custom URL scheme for your app (e.g., "myapp") |
| bundleId | string | ❌ | iOS bundle identifier (defaults to your app's bundle ID) |
| enableUniversalLinks | boolean | ❌ | Enable universal links support for iOS (default: false) |
2. Configure your OAuth provider
Make sure your OAuth provider (Google, Auth0, etc.) is configured with the correct redirect URI:
For custom scheme:
com.org.myapp.auth://oauth/redirectFor universal links (if enabled):
https://myapp.com/oauth/redirectUsage
Basic OAuth Flow
import { authorize, refresh } from 'react-native-app-auth';
const GOOGLE_OAUTH_APP_GUID = 'YOUR_GOOGLE_OAUTH_APP_GUID'; // it looks something like 12345678912-k50abcdefghijkabcdefghijkabcdefv
const config = {
issuer: 'https://accounts.google.com',
clientId: `${GOOGLE_OAUTH_APP_GUID}.apps.googleusercontent.com`,
redirectUrl: `com.googleusercontent.apps.${GOOGLE_OAUTH_APP_GUID}:/oauth2redirect/google`,
scopes: ['openid', 'profile'],
// Optional: additional configuration
useNonce: true,
usePKCE: true,
};
// Perform the login
const handleLogin = async () => {
try {
const result = await authorize(config);
console.log('Access Token:', result.accessToken);
console.log('ID Token:', result.idToken);
console.log('Refresh Token:', result.refreshToken);
} catch (error) {
console.error('Authentication error:', error);
}
};
// Refresh token
const handleRefresh = async (refreshToken: string) => {
try {
const result = await refresh(config, {
refreshToken: refreshToken,
});
console.log('New Access Token:', result.accessToken);
} catch (error) {
console.error('Token refresh error:', error);
}
};License
MIT
