Step 2. Configure connection properties
PingOne Advanced Identity Cloud React Native
In this step, you install the project dependencies and configure the reactnative-oidc sample to connect to the OAuth 2.0 application you created in PingOne Advanced Identity Cloud.
|
Run all the commands on this page from the sample app’s project root folder, |
Installing dependencies
-
Install the JavaScript dependencies:
yarn install -
iOS only, install the native CocoaPods dependencies:
cd ios bundle install bundle exec pod install cd .. -
On Android only, configure a keystore and add the passwords as follows:
-
Generate a debug signing keystore:
keytool -genkeypair -v \ -keystore android/app/debug.keystore \ -alias androiddebugkey \ -keyalg RSA -keysize 2048 -validity 10000 \ -storepass 5tr0ngP@S5w0rd! -keypass 5tr0ngP@S5w0rd! \ -dname "CN=Android Debug,O=Android,C=US"Replace 5tr0ngP@S5w0rd! with a password of your choice, using the same value for both the
-storepassand-keypassparameters.The generated keystore file must be located in
sdk-sample-apps/reactnative/reactnative-oidc/android/app/debug.keystore, and use the aliasandroiddebugkey.The build will fail if the keystore file is missing, or if the passwords in your Gradle properties do not match those used when generating the keystore.
-
Add the keystore credentials to your global Gradle properties file, for example at
~/.gradle/gradle.properties:KEYSTORE_PASSWORD=5tr0ngP@S5w0rd! KEY_PASSWORD=5tr0ngP@S5w0rd!
-
Configuring connection properties
-
Copy the example environment file:
cp .env.example .env -
Open
.envin a text editor and update theAIC_values to match your environment:Example values in the .env fileAIC_CLIENT_ID=sdkPublicClient AIC_DISCOVERY_ENDPOINT=https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration AIC_REDIRECT_URI=org.forgerock.oidc://oauth2redirect AIC_SCOPES=openid, email, address, profile- AIC_CLIENT_ID
-
The client ID of the OAuth 2.0 application you registered in PingOne Advanced Identity Cloud.
For example,
sdkPublicClient - AIC_DISCOVERY_ENDPOINT
-
The
.well-knownOpenID Connect discovery endpoint for your tenant.How do I find my PingOne Advanced Identity Cloud
.well-knownURL?You can view the
.well-knownendpoint for an OAuth 2.0 client in the PingOne Advanced Identity Cloud admin console:-
Log in to your PingOne Advanced Identity Cloud administration console.
-
Click Applications, and then select the OAuth 2.0 client you created earlier. For example, sdkPublicClient.
-
On the Sign On tab, in the Client Credentials section, copy the Discovery URI value.
For example,
https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/alpha/.well-known/openid-configuration
If you are using a custom domain, your
.well-knownis formed as follows:https://<custom-domain-fqdn>/.well-known/openid-configurationLearn more in Access OIDC configuration discovery endpoint.
For example,
https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration -
- AIC_REDIRECT_URI
-
The redirect URI configured in your OAuth 2.0 client profile.
This value must exactly match a redirect URI registered in your server.
For this tutorial, the sample application is pre-configured to use the following redirect URI:
org.forgerock.oidc://oauth2redirect.If you use a different redirect scheme, you must also update the values in the following locations:
-
Android -
manifestPlaceholders["appRedirectUriScheme"]insdk-sample-apps/reactnative/reactnative-oidc/android/app/build.gradle -
iOS -
CFBundleURLSchemesinsdk-sample-apps/reactnative/reactnative-oidc/ios/PingSampleApp/Info.plist -
The OAuth 2.0 client settings in the server
-
- AIC_SCOPES
-
A comma-separated list of OAuth 2.0 scopes to request.
For example,
openid, email, address, profile
-
Save your changes.
With the environment file configured, the React Native app will pick up your settings the next time you build and run it.