I'm using angular 8 and spring boot both applications are deployed in azure app services and using ad authentications. In ui I'm using adal-angular4 lib for getting token details. Using that I can able to get access token using this method .acquireToken('< spring service client Id >') to access my spring application. It is working fine i can able to get the response. but i want to get user details, group information and role details using that access token in spring application. I don't know how to get those details. please any one help me. Thanks
0
votes
1 Answers
0
votes
If you want to get the detailed information of Azure AD group or Azure AD user, you can use Microsoft Graph API. For example
Register a new application using the Azure portal
Sign in to the Azure portal using either a work or school account or a personal Microsoft account.
If your account gives you access to more than one tenant, select your account in the top right corner, and set your portal session to the Azure AD tenant that you want.
- In the left-hand navigation pane, select the Azure Active Directory service, and then select App registrations > New registration.
Configure Microsoft Graph permissions you need for your application [![enter image description here][3]][3]
Code
# install package microsoft-graph, microsoft-graph-core, microsoft-graph-auth
ClientCredentialProvider authProvider = new ClientCredentialProvider(CLIENT_ID, SCOPES, CLIENT_SECRET, TENANT_GUID, NATIONAL_CLOUD);
IGraphServiceClient graphClient = GraphServiceClient
.builder()
.authenticationProvider(authProvider)
.buildClient();
# get group
Group group = graphClient.groups("object")
.buildRequest()
.get();
#
IUserCollectionPage users = graphClient.users()
.buildRequest()
.get();
For more details, please refer to
https://docs.microsoft.com/en-us/graph/overview-major-services