React Native OAuth

Matt Chaffe
Code and Wires
Published in
4 min readJan 11, 2019

--

I just want to start with I have little to no experience with React or React Native so there are likely things I am doing which could be improved, but I wanted to learn and have to start somewhere.

I decided to begin with getting an OAuth workflow within React Native. I’m going to run through this from a Mac OSX user perspective, and for a target of iOS.

Getting Started

Where better to get started than following the Getting Started guide, I initially followed the Expo flow as this was the one which is shown by default. But I soon learned that with OAuth you need to install some native dependencies for the Auth flow.

To create the app initially it’s fairly straight forward, install the cli npm install -g react-native-cli and then create your project react-native init MyAwesomeAuthApp.

Adding Auth

Installation

For the Auth, I am going to use the React Native App Auth package, which allows OAuth 2.0 and OpenID Connect providers.

Install and link the native package via the following:

npm i react-native-app-auth
react-native link react-native-app-auth

The link part is what adds the native dependencies to the ios and andriod builds. I opted to use the Carthage…

--

--