# React native error Invalid state received in redirect URL

**URL:** <https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536>\
**Category:** Get Help\
**Tags:** react-native\
**Created:** [July 16, 2017, 5:56am UTC](https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536 "2017-07-16T05:56:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinit](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@vinit](https://community.auth0.com/u/vinit)\
**Post date:** [July 16, 2017, 5:56am UTC](https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536/1 "2017-07-16T05:56:11Z")

</div>

I’m getting error: “state Invalid state recieved in redirect url”

I’m using hosted pages with Lock as below

```
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
      auth: {
        redirectUrl: config.callbackURL,
         responseType: (config.internalOptions || {}).response_type ||
          config.callbackOnLocationHash ? 'token' : 'code',
        params: {
            scope: 'openid'
        }
      },
      assetsUrl: config.assetsUrl,
      allowedConnections: 'facebook', 'twitter'],
      rememberLastLogin: !prompt,
      language: language,
      languageDictionary: {
        title: 'Log in'
      },
      theme: {
        logo: 'https://s3-us-west-2.amazonaws.com/rune-public/images/icon256.png',
        //primaryColor: 'green'
      },
      prefill: loginHint ? { email: loginHint, username: loginHint } : null,
      // uncomment if you want small buttons for social providers
      socialButtonStyle: 'big',
      closeable: true
    });

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [July 17, 2017, 10:17pm UTC](https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536/2 "2017-07-17T22:17:09Z")

</div>

The template that makes use of Lock in the hosted login page sets the `auth.params` property of the options to `config.internalOptions`. **However, in your code sample, you replaced that with `params: { scope: 'openid' }`** which means Lock is not configured correctly with the internal options required to its use as part of the hosted login page.

In general, the scope parameter is sent from the application so I also fail what is the exact use case you require that lead you to having a configuration such as that one. Nonetheless, the reason for the error in question is the incorrect configuration of Lock; you’ll need to make use of the internal options.

---

<div class="post-metadata">

**Author:** ![vinit](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@vinit](https://community.auth0.com/u/vinit)\
**Post date:** [July 18, 2017, 2:34am UTC](https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536/3 "2017-07-18T02:34:50Z")

</div>

Thanks for your response.

So here my client code :

```
 {
            auth0
                .webAuth
                .authorize({ scope: 'openid email', audience: 'https://example.com/userinfo' })
                .then(credentials => {
                    console.log(credentials)
                }
                // Successfully authenticated
                // Store the accessToken
                ).catch((error) => {
                    console.log(error);
                });
        }

```

here is my hosted page loc initialization :

```
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
      auth: {
        redirectUrl: config.callbackURL,
         responseType: 'token',
        params: config.internalOptions
      },
      assetsUrl: config.assetsUrl,
      allowedConnections: 'facebook', 'twitter'],
      rememberLastLogin: !prompt,
      language: language,
      languageDictionary: {
        title: 'Log in'
      },
      theme: {
        logo: 'xyz.png',
        //primaryColor: 'green'
      },
      prefill: loginHint ? { email: loginHint, username: loginHint } : null,
      // uncomment if you want small buttons for social providers
      socialButtonStyle: 'big',
      closeable: true
    });

    lock.show();

```

here is the response that comes to ios with url value:  
example.native://xxxxxx-xxxxx.auth0.com/ios/example.native/callback?code=adfadsfadsdsse&state=adsfasfadsasdfasdafd-qYoFVJGvtAesUg

Now if i call authorize again then i get the credential then to execute. what am i doing wrong?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/react-native-error-invalid-state-received-in-redirect-url/7536/4 "2018-03-02T05:55:25Z")

</div>


