Hello community,
I am new to APIs and for sure to Microsoft Grant APIs.
I have followed the instructions in the articles below to register a new application.
In one of the articles that explains how to access token is better to use the Microsoft Authentication Library (MSAL) (see third link).
I was able to follow the instructions accordingly and clone the application provided by MS in GitHub (see 4th link).
The request was successful as I have inserted my tenant details successfully in this code and run the file:
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "Enter the tenant ID obtained from the Microsoft Entra admin center",
"ClientId": "Enter the client ID obtained from the Microsoft Entra admin center",
"ClientCertificates": [
{
"SourceType": "StoreWithThumbprint",
"CertificateStorePath": "CurrentUser/My",
"CertificateThumbprint": "Enter the certificate thumbprint obtained the Microsoft Entra admin center"
}
],
"CallbackPath": "/signin-oidc"
},
"DownstreamApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0/",
"RelativePath": "me",
"Scopes": [
"user.read"
]
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
However, when I change the RelativePath to "me/messages" to get all my emails I received the following error:
An unhandled exception occurred while processing the request.
HttpRequestException: Invalid status code in the HttpResponseMessage: Unauthorized: {"error":{"code":"AuthOMMissingRequiredPermissions","message":"The AadGuestPft token doesn't contain the permissions required by the target API for calling app...
Further, I have also tried to get an access token by running the following link:
https://login.microsoftonline.com/[mytenant]/oauth2/v2.0/token -> (have removed my tenant id but was located at [mytenant]
But I have also getting this message:
Sorry, but we’re having trouble signing you in.
AADSTS900561: The endpoint only accepts POST, OPTIONS requests. Received a GET request.
Can someone please help me this? I would need to also query this data for other people in my organization.
Any help will be much appreciated.
Instructions Followed
https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app
https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http#use-the-microsoft-authentication-library-msal
https://learn.microsoft.com/en-us/graph/auth/auth-concepts
https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-web-app-dotnet-core-sign-in