Hi Okta Forum,
I am having a ReactJS SPA and I am trying to create a SignIn functionality using Okta.
Let me explain my use case:
So when you launch the application it takes you to a Landing page. This landing page has 3 routes inside it implemented.
if its (“/”) it takes to AuthenticationComponent
(“/login/callback”) takes it to LoginCallbackComponent which just redirects the user to /home
(“/home”) takes you to homepage of application
This landing page renders an “AuthenticationComponent” where user can sign in through simple email password based functionality or SSO using Okta SignIn.
Now when the user clicks on SSO button, it triggers this function:
const oktaAuth = new OktaAuth(oktaAuthConfiguration);
export const login = async (oktaAuth) => {
try {
await oktaAuth.signInWithRedirect();
} catch (error) {
console.error("Login error", error);
}
};
My oktaAuthConfiguration looks something like this:
export const oktaAuthConfiguration = {
issuer: `https://carrier.oktapreview.com`,
clientId: "******************",
clientSecret:
"***************",
redirectUri: `${window.location.origin}/login/callback`,
responseType: ["code"], // Use 'code' for authorization code flow
scopes: ["openid", "profile", "email"],
pkce: true,
};
I am trying to fetch the user data after signing in but I am unable to get that. What wrong I am doing. I am very new to this and unable to understand how to do this. I went through documentation but it didn’t help much.
Will appreacite any help!