Access_denied: Unauthorized after successful login

I am followed the Quick start for React Native and created a Sample App.
App launches and after clicking on login button it opens up Auth0 browser for login/signup.
After Login or Signup it closes the browser and logs
access_denied: Unauthorized
However in Logs, it says that it was a successful login.
Following is the code I am using on button click
auth0
.webAuth
.authorize({scope: ‘openid profile email’})
.then(credentials =>
console.log(“Logged In”)
)
.catch(error => console.log(“Error -”,error))

It never goes in Logged in, it falls in catch and gives the error.
Happening on Android (React Native).

2 Likes

Hey there! In order to handle that most effectively I will encourage you to create such GitHub issue in the quickstart repo here:

so that the quickstart maintainers can work with you directly on that hurdle. Thank you!

+1. Any idea? I’m using google, facebook and email/password and is the same for the three of them.

Did any of you have by any chance followed my advice and opened a GitHub issue regarding that?

Yes I did. No response on that .

Can you share that here in the thread so I can link it to repo maintainers?

I am getting the same error on a new auth0 app.

  1. I followed the install instructions for react-native-auth0
  2. I added the schema for my app on the Allowed Callback URLs
  3. I have the following codes
import React from 'react';
import Auth0 from 'react-native-auth0';

import Button from 'components/Button';
import Box from 'components/Box';

const auth0 = new Auth0({
  domain: MYDOMAIN,
  clientId: MYCLIENTID
});

console.log(auth0);

function Login () {
  const login = React.useCallback(async () => {
    try {
      const response = await auth0.webAuth.authorize({ scope: 'openid profile email' });
      console.log(response);
    } catch (error) {
      console.log(error);
    }
  }, []);

  const logout = React.useCallback(async () => {
    await auth0.webAuth.clearSession();
  }, []);

  return (
    <Box flex={1} justifyContent="center" alignItems="center">
      <Button mode="contained" onPress={login}>
        Login
      </Button>
      <Box marginTop={20} />
      <Button mode="outlined" onPress={logout}>
        Clear session
      </Button>
    </Box>
  );
}

export default React.memo(Login);
  1. I created a test user via Dashboard → Users

My first tap on the login button, it displayed the login screen, I typed in the email and password of the test user, a bottom modal appeared but I think the login screen quickly disappeared, I didn’t see it. Then I saw at the console that there was an error saying “access_denied: Unauthorized”, when I tap on the login button again it will quickly close the login screen and then the same error will be logged on the console. Tapping on Clear session button logs the user out successfully though.

EDIT:

I went to Applications (left sidebar) -> Settings (tab) -> Application Properties and set Application Type to Native after a few minutes, it worked.

5 Likes

Thanks for sharing that solution with the rest of community!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.