<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
System Status
Announcements
Announcements
Search
Search
Select Language
0D54z000075uVZWCA2Okta Classic EngineIntegrationsAnswered2021-08-01T11:08:29.000Z2021-07-29T07:21:44.000Z2021-08-01T11:08:29.000Z

AlexanderE.86725 (Customer) asked a question.

How to get the OKTA user's group

Hello,

I'm trying to get the user's group using React. While the code below works as expected I cannot retrieve the user's group from "oktaAuth.getUser()". Is there a way to retrieve this info?

 

import { useOktaAuth } from "@okta/okta-react";

import React, { useState, useEffect } from "react";

 

const Home = () => {

const { authState, oktaAuth } = useOktaAuth();

const [userInfo, setUserInfo] = useState(null);

 

useEffect(() => {

if (!authState.isAuthenticated) {

// When user isn't authenticated, forget any user info

setUserInfo(null);

} else {

oktaAuth.getUserInfo().then(info => {

setUserInfo(info);

});

}

}, [authState, oktaAuth]); // Update if authState changes

 

return (

<div>

{userInfo && (

<div>

<p>Welcome back, {userInfo.name}!</p>

</div>

)}

</div>

);

};

 

export default Home;

 


This question is closed.
Loading
How to get the OKTA user's group
Okta Support Agent (Beta)

Terms of Service

Hello! I'm the Okta Support Agent (Beta), your go-to resource for questions about Okta products. Please remember for your security and privacy, do not share any Personally Identifiable Information (PII) such as passwords, IP addresses, or other details with me.

Okta Privacy Policy and Terms of Service apply