I have a delphi desktop application and would like to use Graph API to get inforamation from Office 365. I registered the app in Entra. I got the access token, and when I tried to use the token to get user profile (https://graph.microsoft.com/v1.0/me), I got the error message 'HTTP/1.1 401 Unauthorized'.
When I registered the app in Entra, the permission 'User.Read' is enabled under Graph. And also when the token is generated, the scope 'User.Read' is also set.
When I run test in Postman with the token I get, I have the response with 200 OK.
Here is the code to call Graph api:
RESTClient.BaseURL := FConnection.RESTEndPoint; // https://graph.microsoft.com
RESTListResGroupRequest.Resource := 'v1.0/me';
RESTListResGroupRequest.Params.Clear;
RESTListResGroupRequest.Params.AddItem('Authorization', 'Bearer ' + FConnection.AuthToken, TRESTRequestParameterKind.pkHTTPHEADER, [poDoNotEncode]);
RESTListResGroupRequest.Params.AddItem('Content-Type', 'application/json', TRESTRequestParameterKind.pkHTTPHEADER);
RESTListResGroupRequest.ExecuteAsync;
What could be the problem?