This demo application shows how to do the federation process with an OAuth provider using the library react-native-app-auth.
Prerequisites: Node.js and Xcode (for iOS/Mac) or Android Studio (for Android).
git clone https://github.com/embesozzi/oidc-demoapp-reactnative.git
cd oidc-demoapp-reactnative
yarn install
Create an OAuth client as a Public client with the following information: client id (e.g., oidc-demoapp-reactnative
), scopes (e.g., openid profile
), grant type Authorization Code
and define the Login redirect URI (e.g., com.identicum.demo.mobile:/callback
).
Open App.js
and adjust the initialization of react-native-app-auth
with your settings.
provider : {
issuer: '{idpIssuer}',
clientId: '{clientId}',
redirectUrl: 'com.identicum.demo.mobile:/callback'
...
serviceConfiguration: {
authorizationEndpoint: '{idpAauthorizationEndpoint}',
tokenEndpoint: '{idpTokenEndpoint}',
revocationEndpoint: '{idpRevocationEndpoint}'
}
}
};
Update ios/demoapp/Info.plist
and android/app/build.gradle
to replace the redirect scheme (com.identicum.demo.mobile:/callback
) with the one that matches your native app's redirect URI.
To run the app on iOS, you'll first need to install CocoaPods:
sudo gem install cocoapods
Then cd
into the ios
directory and run pod install
. Then you can run the following command to start and deploy the app into iOS Simulator.
npm run ios
You should see the demoapp
pod being installed and linked to the sample app.
To run the app on Android, you'll have to an Android Virtual Device (AVD). Open Android Studio, select open existing project, and choose the android
directory in your cloned project. If you're prompted to update anything, approve it.
To create a new AVD, navigate to Tools > Android > AVD Manager. Create a new Virtual Device and run it. I recommend using Pixel 2 with Android API 27 x86
.
npm run android
This example uses the following libraries: