Hi @Ali Sultan
The /me
endpoint represents the logged in user and only supports delegated permissions, so you should use the delegated authentication flow (ROPC flow or auth code flow) to obtain the access token, as stated in the error message.
final UsernamePasswordCredential usernamePasswordCredential = new UsernamePasswordCredentialBuilder()
.clientId("xxxxxxxxxxxxxxxxxxxxx")
.username("xxxxxxxxxxxxxxxxxxxx")
.password("xxxxxxxx")
.build();
final List<String> scopes = Arrays.asList("OnlineMeetings.ReadWrite");
final TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(scopes, usernamePasswordCredential);
final GraphServiceClient graphClient =
GraphServiceClient
.builder()
.authenticationProvider(tokenCredentialAuthProvider)
.buildClient();
OnlineMeeting onlineMeeting = new OnlineMeeting();
onlineMeeting.startDateTime = OffsetDateTimeSerializer.deserialize("2023-10-12T21:30:34.2444915+00:00");
onlineMeeting.endDateTime = OffsetDateTimeSerializer.deserialize("2023-10-12T22:00:34.2464912+00:00");
onlineMeeting.subject = "User Token Meeting";
onlineMeeting = graphClient.me().onlineMeetings()
.buildRequest()
.post(onlineMeeting);
System.out.println(onlineMeeting.id + "\n" + onlineMeeting.joinWebUrl);
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.