Sorry, I was multi-posting.
I got the answer on StackOverFlow.
The authentication method was changed to the Interactive provider method and the Azure configuration was changed to accommodate this.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can I use FindMeetingTimes in the Graph API (SDK 5.35) from Azure Function to retrieve available appointments?
If you run a common sample, you will get
GraphClient.Me.FindMeetingTimes, [/me request is only valid with delegated authentication flow.] error
If GraphClient.Users["id"].FindMeetingTimes, [Invalid user address] error
The following is the result.
Sorry, I was multi-posting.
I got the answer on StackOverFlow.
The authentication method was changed to the Interactive provider method and the Azure configuration was changed to accommodate this.
Updated - Client credential flow can be implemented like this
api reference.
please refer the CarlZhao-MSFT answer
Hi @夏目 貴明
Do not use the client credentials flow for this API as it does not support application permissions. You should request the access token using a delegated authentication flow (auth code flow or ROPC flow) with user participation.
Code example:
// Dependencies
using Microsoft.Graph.Me.FindMeetingTimes;
using Microsoft.Graph.Models;
using Microsoft.Graph;
using Azure.Identity;
var scopes = new[] { "Calendars.ReadWrite.Shared" };
var tenantId = "TENANT_ID";
// Values from app registration
var clientId = "YOUR_CLIENT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";
// For authorization code flow, the user signs into the Microsoft
// identity platform, and the browser is redirected back to your app
// with an authorization code in the query parameters
var authorizationCode = "AUTH_CODE_FROM_REDIRECT";
// using Azure.Identity;
var options = new AuthorizationCodeCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
// https://learn.microsoft.com/dotnet/api/azure.identity.authorizationcodecredential
var authCodeCredential = new AuthorizationCodeCredential(
tenantId, clientId, clientSecret, authorizationCode, options);
var graphClient = new GraphServiceClient(authCodeCredential, scopes);
// Code snippets are only available for the latest version. Current version is 5.x
var requestBody = new FindMeetingTimesPostRequestBody
{
Attendees = new List<AttendeeBase>
{
new AttendeeBase
{
Type = AttendeeType.Required,
EmailAddress = new EmailAddress
{
Name = "Alex Wilbur",
Address = "alexw@contoso.onmicrosoft.com",
},
},
},
LocationConstraint = new LocationConstraint
{
IsRequired = false,
SuggestLocation = false,
Locations = new List<LocationConstraintItem>
{
new LocationConstraintItem
{
ResolveAvailability = false,
DisplayName = "Conf room Hood",
},
},
},
TimeConstraint = new TimeConstraint
{
ActivityDomain = ActivityDomain.Work,
TimeSlots = new List<TimeSlot>
{
new TimeSlot
{
Start = new DateTimeTimeZone
{
DateTime = "2023-12-11T09:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2023-12-11T17:00:00",
TimeZone = "Pacific Standard Time",
},
},
},
},
IsOrganizerOptional = false,
MeetingDuration = TimeSpan.Parse("PT1H"),
ReturnSuggestionReasons = true,
MinimumAttendeePercentage = 100d,
};
var result = await graphClient.Me.FindMeetingTimes.PostAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "outlook.timezone=\"Pacific Standard Time\"");
});
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.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more