I’m getting a really strange error and I need some help with it.
I’m in the process of trying to move my sign-in functionality into the main part of my react-native app. I have a <Header />
component that I’m adding to the main screen of the react-native bootstrap. auth0.webAuth.clearSession()
appears to be working by launching the default website to login.
However, auth0.webAuth.authorize()
isn’t launching. Here’s what I have below:
// App component
import React, { FC } from "react";
import { Header } from "./components/header";
import { HomeScreen } from "./screens";
export const App: FC = () => (
<>
<Header />
<HomeScreen />
</>
);
// <Header />
import React, { FC } from "react";
import { Button, View } from "react-native";
import Auth0, { Options } from "react-native-auth0";
export const authConfig: Options = {
domain: "AUTH0_DOMAIN",
clientId: "AUTH0_CLIENT_ID"
};
export const authClient = new Auth0(authConfig);
export const Header: FC = () => {
const handleLogin = async () => {
try {
console.log("signing in...");
const session = await authClient.webAuth.authorize({
scope: "openid",
audience: "AUTH0_AUDIENCE"
});
console.log(session);
} catch (error) {
console.log(error);
}
};
return (
<View style={{ marginTop: 100 }}>
<Button title="Click to login" onPress={handleLogin} />
</View>
);
};
Here’s the weird thing… there are some instances (which I can barely re-create where auth0.authorize launches the Universal Authentication module.
I’m on RN 61.5
and react-native-auth0: v2.3
.
What could I be missing?