We are looking for a way to retrieve user information that you are signing in to.
I have installed a web application using Java in Web Apps and
We use Azure Active Directory for authentication.
I would like to obtain user information in Java.
As for user information, after signing in to webapps registered with Azure AD,
Enter [web apps] +/.auth/me to access
The browser displays user information json, so I'm going to get that information.
In order to obtain user information, we created the following program, but we were unable to obtain it.
A As you said you need an access token to communicate with Azure AD, I have obtained it in advance.
// Access token
String accessToken= [Retrieved];
// URL for obtaining authenticated user information
URL targetUrl = new URL([webapp]+"/.auth/me";
HttpURLConnection connection=(HttpURLConnection) targetUrl.openConnection();
// Configuring Authentication Headers
connection.setRequestProperty("Authorization", "Bearer" + accessToken);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
// Configuring HTTP Methods
connection.setRequestMethod("GET");
// CONNECTION
connection.connect();
I have a question, but is it possible to get it if I make some modifications to the above program?
Also, is it necessary to obtain it by another method?
I would appreciate it if you could let me know.
If you can retrieve it in your browser and not in your Java program, I think there are other request headers you need.
Use this page to implement the code to add the request header.
© 2024 OneMinuteCode. All rights reserved.