access token to call Microsoft Graph
Trying to use “TMS FNC Core” to get "access token to call Microsoft Graph"
It's a POST call. Is it possible to show an example of how to make the call with Core
access token to call Microsoft Graph
Trying to use “TMS FNC Core” to get "access token to call Microsoft Graph"
It's a POST call. Is it possible to show an example of how to make the call with Core
Hi,
You should be able to do this with the following code:
ACloudBase.Request.Clear;
ACloudBase.Request.Host := 'https://login.microsoftonline.com';
ACloudBase.Request.Path := '/common/oauth2/v2.0/token';
ACloudBase.Request.PostData :=
'client_id=' + TTMSFNCUtils.URLEncode('MyClientID')
+ '&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default'
+ '&client_secret=' + TTMSFNCUtils.URLEncode('MySecret')
+ '&grant_type=client_credentials';
ACloudBase.Request.Method := rmPOST;
ACloudBase.ExecuteRequest(
procedure(const ARequestResult: TTMSFNCCloudBaseRequestResult)
begin
if ARequestResult.Success then
Memo1.Text := ARequestResult.ResultString
else
Memo1.Text := 'Request failed';
end
);