OIDC Enablement for React Native Applications

Okta React Native

The Okta React Native library makes it easy to add authentication to your React Native app. This library is a wrapper around Okta OIDC Android and Okta OIDC iOS.

This library follows the current best practice for native apps using:

This library also exposes APIs to interact with Authentication API directly to implement native UI for authentication.

You can learn more on the Okta + ReactNative page in our documentation. You can also download our sample application


  • If you do not already have a Developer Edition Account, you can create one at https://developer.okta.com/signup/.
  • If you don’t have a React Native app, or are new to React Native, please continue with the React Native CLI Quickstart guide. It will walk you through the creation of a React Native app and other application development essentials.
  • If you are developing with an Android device emulator, make sure to check out the React Native - Android Development setup instructions.

Add an OpenID Connect Client in Okta

In Okta, applications are OpenID Connect clients that can use Okta Authorization servers to authenticate users. Your Okta Org already has a default authorization server, so you just need to create an OIDC client that will use it.

  • Log into the Okta Developer Dashboard, click Applications then Add Application.
  • Choose Native as the platform, then submit the form the default values, which should look similar to this:
Setting Value
App Name My Native App
Login redirect URIs com.mynativeapp:/
Grant Types Allowed Authorization Code, Refresh Token

After you have created the application there are two more values you will need to gather:

Setting Where to Find
Client ID In the applications list, or on the “General” tab of a specific application.
Org URL On the home screen of the developer dashboard, in the upper right.

Note: As with any Okta application, make sure you assign Users or Groups to the OpenID Connect Client. Otherwise, no one can use it.

These values will be used in your React application to setup the OpenID Connect flow with Okta.

Getting started

This library is available through npm. To install it, simply add it to your project:

$ npm install @okta/okta-react-native --save
$ react-native link @okta/okta-react-native

Perform the following Manual installation steps if you’re not using react-native link.

Manual installation (Optional)
  1. In Xcode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules@okta/okta-react-native and add ReactNativeOktaSdkBridge.xcodeproj
  3. In Xcode, in the project navigator, select your project. Add libReactNativeOktaSdkBridge.a to your project’s Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<
  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.oktareactnative.OktaSdkBridgePackage; to the imports at the top of the file
  • Add new OktaSdkBridgePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':@okta/okta-react-native'
    project(':@okta/okta-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/@okta/okta-react-native/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

    compile project(':@okta_okta-react-native')

iOS Setup

To setup iOS, there are three steps that you must take.

  1. Make sure your iOS app’s deployment target is 11.0 and above.
  2. Install Okta Open ID Connect iOS.
  3. Make sure you also configure Swift.
Set iOS Deployment Target

This library supports iOS version 11.0 and above. Go to your project -> Build settings -> iOS Deployment Target, and set it to at least version 11.0.

Install Okta Open ID Connect iOS

This library depends on the native Okta OIDC iOS library. It is not distributed as part of the React Native library to keep your dependency management consistent.

You can currently add Okta OIDC iOS through CocoaPods:

  1. CocoaPods

    React Native >= 0.60: With React Native 0.60 pods are added to podfile automatically. Run pod install command to install dependecies:

    cd ios
    pod install

    React Native < 0.60: Make sure your Podfile looks like this:

    platform :ios, '11.0'
    target '{YourTargetName}' do
    pod 'OktaOidc', '~> 3.0'

    Then run pod install.

  2. Carthage With Carthage, add the following line to your Cartfile:

    github "okta/okta-oidc-ios" ~> 3.5.0

    Then run carthage update --platform iOS.

    Open project settings and choose your application target. Then open Build Phases and add OktaOidc.framework from ios/Carthage/Build/iOS into Embed Frameworks section

Android Setup

For Android, there are two steps that you must take:

  1. Installing Okta Open Id Connect Android.
  2. Add a redirect scheme to your project.
Install Okta Open ID Connect Android

This library depends on the native Okta OIDC Android library. You have to add this library through Gradle. Follow the following steps:

  1. Add this line to android/build.gradle, under allprojects -> repositories.

    maven {
      url  "https://dl.bintray.com/okta/com.okta.android"
  2. Make sure your minSdkVersion is 21 in android/build.gradle.

Add redirect scheme

Defining a redirect scheme to capture the authorization redirect. In android/app/build.gradle, under android -> defaultConfig, add:

manifestPlaceholders = [
  appAuthRedirectScheme: 'com.sampleapplication'


You will need the values from the OIDC client that you created in the previous step to set up. You will also need to know your Okta Org URL, which you can see on the home page of the Okta Developer console.

Before calling any other method, it is important that you call createConfig to set up the configuration properly on the native modules.

Importing methods would follow this pattern:

import { createConfig, signIn, signOut, getAccessToken } from '@okta/okta-react-native';


This method will create a configured client on the native modules. Resolves true if successfully configures a client. Note: requireHardwareBackedKeyStore is a configurable setting only on android devices. If you’re a developer testing on android emulators, set this field to false.

Note: issuer is an optional field in config, for more information please refer to About the Issuer

Note: androidChromeTabColor is an optional field in config, and is used only by Android for the Chrome Custom Tabs color for the OIDC flow.

Note: httpConnectionTimeout and httpReadTimeout are optional fields in config. These are used for HTTP requests performed by the SDK. Timeouts are in seconds.

await createConfig({
  issuer: "https://{yourOktaDomain}/oauth2/default", // optional
  clientId: "{clientId}",
  redirectUri: "{redirectUri}",
  endSessionRedirectUri: "{endSessionRedirectUri}",
  discoveryUri: "https://{yourOktaDomain}",
  scopes: ["openid", "profile", "offline_access"],
  requireHardwareBackedKeyStore: true,
  androidChromeTabColor: "#FF00AA",
  httpConnectionTimeout: 15,
  httpReadTimeout: 10,


This method will return an instance of @okta/okta-auth-js client to communicate with Okta Authentication API. For more information, please checkout Okta AuthJs Node JS and React Native Usage section.


This method will handle both browser-sign-in and custom-sign-in scenarios based on provided options.

This async method will automatically redirect users to your Okta organziation for authentication. It will emit an event once a user successfully signs in. Make sure your event listeners are mounted and unmounted. Note: on iOS there isn’t a onCancelled event. If the sign in process is cancelled, onError will be triggered.


browser-sign-in leverages device’s native browser to automatically redirect users to your Okta organziation for authentication. By providing no argument, this method will trigger the browser-sign-in flow. It will emit an event once a user successfully signs in. Make sure your event listeners are mounted and unmounted. Note: on iOS there isn’t a onCancelled event. If the sign in process is cancelled, onError will be triggered.


Note: IDP can be passed by specifying an argument with the idp parameter.

signInWithBrowser({ idp: 'your_idp_here' });


custom-sign-in provides the way to authenticate the user within the native application. By providing options object with username and password fields, this method will retrieve sessionToken then exchange it for accessToken. Both Promise and Event listeners are supported. This method is leveraging @okta/okta-auth-js SDK to perform authentication API request. For more information, please checkout Okta AuthJs signIn options section.

Sample Usage
signIn({ username: "{username}", password: "{password}" })
  .then(token => {
    // consume accessToken from token.access_token
  .catch(error => {
    // { code: "", message: "", detail: { message: "", status: "" } }
    // handle error
Sample Usage
import { signIn, EventEmitter } from '@okta/okta-react-native';

componentDidMount() {
  this.signInSuccess = EventEmitter.addListener('signInSuccess', function(e: Event) {
    // Do something ...
  this.signOutSuccess = EventEmitter.addListener('signOutSuccess', function(e: Event) {
  this.onError = EventEmitter.addListener('onError', function(e: Event) {
  this.onCancelled = EventEmitter.addListener('onCancelled', function(e: Event) {

componentWillUnmount() {


If you already logged in to Okta and have a valid session token, you can complete authorization by calling authenticate method. It will emit an event once a user successfully signs in. Make sure your event listeners are mounted and unmounted. Note: on iOS there isn’t a onCancelled event. If the authenticate process is cancelled, onError will be triggered.

authenticate({sessionToken: sessionToken});


Clear the browser session and clear the app session (stored tokens) in memory. Fires an event once a user successfully logs out. For sample usage, refer to signIn.

Note: This method apply for browser-sign-in scenario only. Use a combination of revokeToken (optional) and clearTokens methods to signOut when use custom-sign-in.

browser-sign-in sample
custom-sign-in sample
await revokeAccessToken(); // optional
await revokeIdToken(); // optional
await clearTokens();


Returns a promise that resolves to true if there is a valid access token or ID token. Otherwise false.

await isAuthenticated();
Sample Response

If authenticated:

  "authenticated": true


  "authenticated": false


This method returns a promise that will return the access token as a string. If no access token is available (either does not exist, or expired), then the promise will be rejected.

await getAccessToken();
Sample Response

If an access token is available:

  "access_token": "{accessToken}"


This method returns a promise that will return the identity token as a string. The promise will be rejected if no id token is available.

await getIdToken();
Sample Response

If an id token is available:

  "id_token": "{idToken}"


Returns a promise that will fetch the most up-to-date user claims from the OpenID Connect /userinfo endpoint.

await getUser();
Sample Response

If a user is available:

  "sub": "00uid4BxXw6I6TV4m0g3",
  "name" :"John Doe",
  "address" : { "street_address":"123 Hollywood Blvd.", "locality":"Los Angeles", "region":"CA", "postal_code":"90210", "country":"US" },
  "phone_number":"+1 (425) 555-1212"


Returns the user claims decoded from the identity token.

await getUserFromIdToken();
Sample Response

Sample user claims:

  "sub": "00uid4BxXw6I6TV4m0g3", 
  "name": "John Doe", 
  "preferred_username": "john.doe@example.com"
  "ver": 1, 
  "iss": "https://dev-example.okta.com", 
  "aud": "00uid4BxXw6I6TV4m0g3",
  "auth_time": 1561679776,
  "exp": 1561683377,
  "iat": 1561679777,
  "idp": "00uid4BxXw6I6TV4m0g3"


Revoke the access token to make it inactive. Resolves true if access token has been successfully revoked.

await revokeAccessToken();


Revoke the identity token to make it inactive. Resolves true if id token has been successfully revoked.

await revokeIdToken();


Revoke the refresh token to make it inactive. Resolves true if refresh token has been successfully revoked.

await revokeRefreshToken();


Removes all tokens from local storage. Resolves true if tokens were successfully cleared.

await clearTokens();


Introspect the access token.

await introspectAccessToken();
Sample Response

Sample responses can be found here


Introspect the id token.

await introspectIdToken();
Sample Response

Sample responses can be found here


Introspect the id token.

await introspectRefreshToken();
Sample Response

Sample responses can be found here


Refreshes all tokens. Resolves with the refreshed tokens.

await refreshTokens();
Sample Response
  "access_token": "{accessToken}", 
  "id_token": "{idToken}", 
  "refresh_token": "refreshToken" 


We welcome contributions to all of our open-source packages. Please see the contribution guide to understand how to structure a contribution.

Installing dependencies for contributions

We use yarn for dependency management when developing this package:

yarn install

Download Details:

Author: okta

Source Code: https://github.com/okta/okta-react-native

#react-native #react #mobile-apps

What is GEEK

Buddha Community

OIDC Enablement for React Native Applications
Autumn  Blick

Autumn Blick


How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms?

React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.

Consult with experts:- https://bit.ly/2A8L4vz

#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native

Hire Dedicated React Native Developers - WebClues Infotech

Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.

Looking for a react native developer?

Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.

WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.

Want to get your app idea into reality with a react native framework?

Get in touch with us.

Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/

For inquiry: https://www.webcluesinfotech.com/contact-us/

Email: sales@webcluesinfotech.com

#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour

Factors affecting the cost of hiring a React Native developer in USA - TopDevelopers.co

Want to develop app using React Native? Here are the tips that will help to reduce the cost of react native app development for you.
Cost is a major factor in helping entrepreneurs take decisions about investing in developing an app and the decision to hire react native app developers in USA can prove to be fruitful in the long run. Using react native for app development ensures a wide range of benefits to your business. Understanding your business and working on the aspects to strengthen business processes through a cost-efficient mobile app will be the key to success.

#best react native development companies from the us #top react native app development companies in usa #cost of hiring a react native developer in usa #top-notch react native developer in usa #best react native developers usa #react native

Know why to consider react native as your next mobile application development

React Native is an open-source framework that gives you wings to create truly native applications that do not compromise on your users’ experiences. TechAhead is a renowned React Native app development company having years of experience and a proven track record of delivering high-quality React Native app development services in record time. Get in touch with the TechAhead consultants to get started with your next mobile app project.
For more details read our full blog here https://dripivplus.com/reasons-to-consider-react-native-for-your-next-mobile-application-development/

#react native app development company #react native app developer #react native app development service #react native app development #react native application development company