Scope value = "https://graph.microsoft.com/.default" OR "https://graph.microsoft.com/beta"
gives below err in asp.net c#.
MsalServiceException: AADSTS500011: The resource principal named https://graph.microsoft.com/v1.0 was not found in the tenant named 'xxxxxxxx'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.
code:
string clientId = AppClientID;
string clientSecret = Secret;
string redirectUri =`enter code here` System.Configuration.ConfigurationManager.AppSettings["redirectUri"];
string authority = "https://login.microsoftonline.com/" + tenantID;
string[] scopes = new string[] { "https://graph.microsoft.com/.default" };
//string[] scopes = new string[] { "https://graph.microsoft.com/beta/.default" };
IConfidentialClientApplication app = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithRedirectUri(redirectUri)
.WithClientSecret(clientSecret)
.WithAuthority(authority)
.Build();
AuthorizationCodeProvider auth = new AuthorizationCodeProvider(app, scopes);
GraphServiceClient graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider(async (requestMessage) =>
{
var authResult = app.AcquireTokenForClient(scopes).WithAuthority(authority, true).ExecuteAsync().Result.AccessToken.ToString();
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult);
}));
var onlineMeeting = new OnlineMeeting
{
StartDateTime = DateTimeOffset.Parse("2021-07-12T21:30:34.2444915+00:00"),
EndDateTime = DateTimeOffset.Parse("2021-07-12T22:00:34.2464912+00:00"),
Subject = "My First MS Teams Meeting"
};
await graphServiceClient.Me.OnlineMeetings.Request().AddAsync(onlineMeeting);
scope
to:https://graph.microsoft.com/.default
– Carl Zhaohttps://graph.microsoft.com/v1.0
is put anywhere in your code. – Allen Wuhttps://graph.microsoft.com/v1.0
orhttps://graph.microsoft.com/v1.0/.default
. Just as Carl suggested, usehttps://graph.microsoft.com/.default
. I think the error you posted here won't occur if you set the scope ashttps://graph.microsoft.com/.default
. – Allen Wu