# Build a React Native Application and Authenticate with OAuth 2.0

**URL:** <https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842>\
**Category:** Developer Blog Comments\
**Created:** [April 20, 2018, 6:21pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842 "2018-04-20T18:21:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [April 20, 2018, 6:21pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/1 "2018-04-20T18:21:56Z")

</div>

[Build a React Native Application and Authenticate with OAuth 2.0](https://developer.okta.com/blog/2018/03/16/build-react-native-authentication-oauth-2)

Learn how to add authentication to your React Native applications with AppAuth and Okta.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 25, 2018, 9:33pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/2 "2018-10-25T21:33:41Z")

</div>

**George Loring**

Thank you for this article. I was able to get it working following your instructions. How would you log out of the application? I can click “Revoke” and that takes me back to the Authorize page but then when I click Authorize it seems like my information is cached because I am not presented with the login page again and I’m logged in. What if we were on a shared device and needed a different person to log in?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 1, 2018, 3:53pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/3 "2018-11-01T15:53:01Z")

</div>

**Matt Raible**

Hello George: you might try [this solution](https://github.com/FormidableLabs/react-native-app-auth/issues/70#issuecomment-427090496 "https://github.com/FormidableLabs/react-native-app-auth/issues/70#issuecomment-427090496"). Add the following to your config:

```
additionalParameters: { prompt: ‘login’}
```

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 9, 2018, 1:05pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/4 "2018-11-09T13:05:41Z")

</div>

**Aske Ertmann**

I had some issues getting this to work with a non developer account. This was due to not having the API Access Management package, that allows for creating custom Authorization Servers, which is used in this example.

However there is a standard Authorization Server available for all accounts without the API Access Management package, which supports PKCE. It’s available at “https://{yourOktaDomain}.okta.com/oauth2” (without the /default part).

However when issuing tokens it uses just “https://{yourOktaDomain}.okta.com”, so use that as issuer without the “/oauth2” part.

Additionally the standard Authorization Server doesn’t provide a OIDC discovery endpoint, so you have to configure the server configuration manually (which also avoids an additional round trip to fetch the configuration).

Here’s the needed configuration:

issuer: ‘https://{yourOktaDomain}.okta.com’,  
clientId: ‘{yourOktaClientId}’,  
redirectUrl: ‘com.okta.{yourOktaDomain}:/callback’,  
serviceConfiguration: {  
 authorizationEndpoint: ‘https://{yourOktaDomain}.okta.com/oauth2/v1/authorize’,  
 tokenEndpoint: ‘https://{yourOktaDomain}.okta.com/oauth2/v1/token’,  
 registrationEndpoint: ‘https://{yourOktaDomain}.okta.com/oauth2/v1/clients’  
}

Hope that helps someone else.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [November 12, 2018, 6:06pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/5 "2018-11-12T18:06:05Z")

</div>

**Matt Raible**

Hello Aske: while this might work, it’s not the recommended setup. It will work if you need an ID token **only**. You won’t be able to validate the access token returned for your APIs. If you want to validate the access token returned for your APIs, you need to use a custom Authorization Server (not the one defined for your org). When you create a new developer account, a custom AS (called “default”) is created for you. To use this one, the issuer (and subsequent values) should be `https://{yourOktaDomain}.okta.com/oauth2/default`.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 23, 2019, 11:56am UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/6 "2019-01-23T11:56:30Z")

</div>

**Daniel Sierra**

Hello. How can I do if I have my own login screen on my app and I don’t want to be asked for the username and password twice (on the device on my app and then on the Okta’s callback page)?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 23, 2019, 4:45pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/7 "2019-01-23T16:45:32Z")

</div>

**Matt Raible**

Hello Daniel - we do plan to add native sign-in for React Native (and the rest of our mobile SDKs) this year. Unfortunately, it’s not available yet.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 24, 2019, 7:26pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/8 "2019-01-24T19:26:28Z")

</div>

**Andy Herzog**

Hi Matt, tagging on to this request. If I add `additionalParameters: { prompt: ‘login’}` I get prompted for my password but it does not allow me to change usernames. If I click the “sign out” button I can change the username but upon successful log in I am brought to my Okta dashboard rather than back to my application. Is there a way to prompt for both username and password instead of just password?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [January 24, 2019, 7:30pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/9 "2019-01-24T19:30:28Z")

</div>

**Matt Raible**

AFAIK, this is a missing feature in the React Native App Auth library. You might want to check out [this issue](https://github.com/FormidableLabs/react-native-app-auth/issues/223 "https://github.com/FormidableLabs/react-native-app-auth/issues/223") or open a new one.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [May 1, 2019, 2:19pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/10 "2019-05-01T14:19:53Z")

</div>

**Juan De la Cruz**

Formidable’s example is no longer available 😕 (the one which we are going to get the assets and components from)

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [May 1, 2019, 2:25pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/11 "2019-05-01T14:25:36Z")

</div>

**Matt Raible**

Thanks for the heads up. The example is still there, the paths have just changed:

```
svn export https://github.com/FormidableLabs/react-native-app-auth/trunk/Example/Latest/componentssvn export https://github.com/FormidableLabs/react-native-app-auth/trunk/Example/Latest/assets
```

I’ll update this post.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [June 20, 2019, 1:52pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/12 "2019-06-20T13:52:42Z")

</div>

**Biathanatos**

@disqus\_JeTrXe41Sl:disqus It looks like prompting it to `select_account` instead is intended, but that hasn’t worked for me with Okta.  
[https://github.com/Formidab…](https://github.com/FormidableLabs/react-native-app-auth/blob/44a47c524dd20ec47595ece6730f650d70ac6078/index.d.ts#L23 "https://github.com/FormidableLabs/react-native-app-auth/blob/44a47c524dd20ec47595ece6730f650d70ac6078/index.d.ts#L23")

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [June 20, 2019, 3:08pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/13 "2019-06-20T15:08:24Z")

</div>

**Andy Herzog**

Good find, unfortunately looks like that is not one of Okta’s allowed values. [https://developer.okta.com/…](https://developer.okta.com/docs/reference/api/oidc/#parameter-details "https://developer.okta.com/docs/reference/api/oidc/#parameter-details")

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 18, 2019, 6:26am UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/14 "2019-07-18T06:26:35Z")

</div>

**Kory Sasaoka**

Hi Matt, thanks for the article. Any word on native sign-in?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 18, 2019, 9:38am UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/15 "2019-07-18T09:38:41Z")

</div>

**piyush tripathi**

In the backend code , where are we validating the access token sent in the request . I couldn’t find it , or may be I’m not looking at the right place.  
Edit - Is it auto-configured by spring-security-oauth2-autoconfigure dependency and doesn’t require any code ?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 30, 2019, 4:02am UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/16 "2019-07-30T04:02:14Z")

</div>

**Matt Raible**

This is handled by the Okta Spring Boot Starter and the autoconfigure dependency. You can see them in the example’s code [here](https://github.com/oktadeveloper/spring-boot-react-example/blob/okta/server/pom.xml#L40 "https://github.com/oktadeveloper/spring-boot-react-example/blob/okta/server/pom.xml#L40"). Okta’s Spring Boot Starter is configured from [application.properties](https://github.com/oktadeveloper/spring-boot-react-example/blob/okta/server/src/main/resources/application.properties "https://github.com/oktadeveloper/spring-boot-react-example/blob/okta/server/src/main/resources/application.properties").

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 31, 2019, 2:34pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/17 "2019-07-31T14:34:49Z")

</div>

**Tobias Gerstenberg**

I’d second that. While Authorization Code Grant seems to be best practice from a security perspective, a browser redirect after opening a native mobile app was deemed “suprising” and “strange” by our users. Any update on when custom in-app login will be possible with React Native & Okta would be appreciated.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [July 31, 2019, 3:44pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/18 "2019-07-31T15:44:39Z")

</div>

**Matt Raible**

Hello Tobias,

I talked to our engineering team this morning. Native sign-in is available for our [Android SDK](https://github.com/okta/okta-oidc-android "https://github.com/okta/okta-oidc-android") and [iOS SDK](https://github.com/okta/okta-oidc-ios "https://github.com/okta/okta-oidc-ios"). Adding native sign-in for React Native is on our roadmap, but not scheduled. I’m sorry we can’t be more firm about dates.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 11, 2019, 6:06pm UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/19 "2019-09-11T18:06:21Z")

</div>

**Doriya Spielman**

Work well thank you! after Im signing in how can i move to another screen?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [March 7, 2020, 3:11am UTC](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842/20 "2020-03-07T03:11:26Z")

</div>

**Pranav Kumar Prasad**

Hi Matt, thank you for this. I am actually trying to implement a social login with Okta along with PKCE, in React Native CLI. I have already integrated google idp with my Okta account, but finding it a bit tricky to use it in React Native…any help here…? Thanks.

[Next page](https://devforum.okta.com/t/build-a-react-native-application-and-authenticate-with-oauth-2-0/16842.md?page=2)
