Microsoft Security | Microsoft Graph
An API that connects multiple Microsoft services, enabling data access and automation across platforms
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
While using the msgraph-sdk-java to access mailbox by application only .
I can list all users.
When I try to list all mail by the below method ,
public static MessageCollectionResponse listMail(String userId) throws Exception {
// /users/{id | userPrincipalName}/messages/{id}/attachments/{id}/$value
if (_appClient == null) {
throw new Exception("Graph has not been initialized for app-only auth");
}
//GET /users/{id | userPrincipalName}/messages
return _appClient.users().byUserId(userId).messages().get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"sender", "subject"};
});
}
it response 401 .
Does this need to access with a user?
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>6.33.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.11.0</version>
</dependency>
An API that connects multiple Microsoft services, enabling data access and automation across platforms
Hi @WuWanning
Please check the following:
Mail.ReadBasic.All, Mail.ReadWrite and Mail.Read application permissions and has been consented by the administrator.Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.