Everything you need to effectively run and manage your APIs is right here.
Native applications can work with different types of mobile app applications.
Even if the name is native
you can use that for react native applications too.
So native application is a proper one for:
You can choose the correct SDKs to integrate with the platforms listed above:
npm install auth0-js @auth0/cordova --save
flutter pub add auth0\_flutter
npm install react-native-auth0 --save
npm install @auth0/auth0-angular
npm install @capacitor/browser @capacitor/app
Install-Package Auth0.OidcClient.iOS
Install-Package Auth0.OidcClient.Android
The guides below demonstrates how to integrate your Native Application with the Identity Product, on our development, testing, staging and production environments.
Before we are able to create your application and share the needed details you need to provide:
{YOUR\_APP\_PACKAGE\_NAME\_OR\_CUSTOM\_SCHEME}://{IDENTITY\_DOMAIN}/android/{YOUR\_APP\_PACKAGE\_NAME}/callback
com.mobile.android.app://ba-stg.identity.stg.iagl.digital/android/com.mobile.android.app/callback
{YOUR\_BUNDLE\_IDENTIFIER\_OR\_CUSTOM\_SCHEME}://{IDENTITY\_DOMAIN}/ios/{YOUR\_BUNDLE\_IDENTIFIER}/callback
com.mobile.ios.app://ba-stg.identity.stg.iagl.digital/android/com.mobile.ios.app/callback
After sharing the needed details (above) we will provide, per environment
npm install react-native-auth0 --save
yarn add react-native-auth0
{ "expo":
{
...
"plugins":
[
[ "react-native-auth0",
{
"domain": "IDENTITY_DOMAIN",
"customScheme": "YOUR_CUSTOM_SCHEME" // this optional, if you dont use remember to use your identity,
}
]
]
}
}
{YOUR\_APP\_PACKAGE\_NAME\_OR\_CUSTOM\_SCHEME}://{IDENTITY\_DOMAIN}/android/{YOUR\_APP\_PACKAGE\_NAME}/callback
{YOUR\_BUNDLE\_IDENTIFIER\_OR\_CUSTOM\_SCHEME}://{IDENTITY\_DOMAIN}/ios/{YOUR\_BUNDLE\_IDENTIFIER}/callback
import React from 'react'
import { Button, Text, View } from 'react-native'
import { useAuth0, Auth0Provider as IdentityProvider } from 'react-native-auth0'
const Home = () => {
const { authorize, clearSession, user } = useAuth0()
const onLogin = async () => {
try {
await authorize({ scope: 'openid profile email' })
} catch (e) {
console.log(e)
}
}
const onLogout = async () => {
try {
await clearSession()
} catch (e) {
console.log('Log out cancelled')
}
}
const loggedIn = user !== undefined && user !== null
return (
<View style={styles.container}>
{loggedIn && <Text>You are logged in as {user.name}</Text>}
{!loggedIn && <Text>You are not logged in</Text>}
<Button
onPress={loggedIn ? onLogout : onLogin}
title={loggedIn ? 'Log Out' : 'Log In'}
/>
</View>
)
}
const App = () => {
return (
<IdentityProvider domain={'IDENTITY_DOMAIN'} clientId={'YOUR_CLIENT_ID'}>
<Home />
</IdentityProvider>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
})
export default App
useAuth0
. That hook will provide a user property for you and if
that's empty it's because the user is not authenticated.useAuth0
and IdentityProvider
npm install react-native-auth0 --save
yarn add react-native-auth0
cd ios
pod install
build.gradle
native code:android {
defaultConfig {
// Add the next line
manifestPlaceholders = [auth0Domain: "IDENTITY_DOMAIN", auth0Scheme: "${applicationId}"]
}
...
}
ios/<YOUR PROJECT>/AppDelegate.mm
):#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return [RCTLinkingManager application:app openURL:url options:options];
}
ios
folder, open the Info.plist
and locate the value for
CFBundleIdentifier
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
Info.plist
keys for CFBundleURLTypes
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>
import React from 'react'
import { Button, Text, View } from 'react-native'
import { useAuth0, Auth0Provider as IdentityProvider } from 'react-native-auth0'
const Home = () => {
const { authorize, clearSession, user } = useAuth0()
const onLogin = async () => {
try {
await authorize({ scope: 'openid profile email' })
} catch (e) {
console.log(e)
}
}
const onLogout = async () => {
try {
await clearSession()
} catch (e) {
console.log('Log out cancelled')
}
}
const loggedIn = user !== undefined && user !== null
return (
<View style={styles.container}>
{loggedIn && <Text>You are logged in as {user.name}</Text>}
{!loggedIn && <Text>You are not logged in</Text>}
<Button
onPress={loggedIn ? onLogout : onLogin}
title={loggedIn ? 'Log Out' : 'Log In'}
/>
</View>
)
}
const App = () => {
return (
<IdentityProvider domain={'IDENTITY_DOMAIN'} clientId={'YOUR_CLIENT_ID'}>
<Home />
</IdentityProvider>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
})
export default App
Please follow what the SDKs recommend and ping us if you need some support with scopes, callback URLs, app name, app logo, or any other native app configuration that you might need (refresh token, expire token time and etc)