Hi Jesper,
You can try to use Fiddler or other tools to capture the HTTP traffic and check the response body.
E.g.: I can see this error from the Server after trying your code using an incorrect ClientSecret :
{"error":"unauthorized_client","error_description":"AADSTS700016: Application with identifier 'e3e65e1b-bcOf-4e02-b777-Oc94df554ed3' was not found in the directory 'AP Pension'. 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 may have sent your authentication request to the wrong tenant. Trace ID: 401cf30c-9fe4-4184-811d-f0063a033400 Correlation ID: 6e170c8d-cdac-4130-b5ab-a07c561e77bc Timestamp: 2024-07-05 01:54:24Z","error_codes":[700016],"timestamp":"2024-07-05 01:54:24Z","trace_id":"401cf30c-9fe4-4184-811d-f0063a033400","correlation_id":"6e170c8d-cdac-4130-b5ab-a07c561e77bc","error_uri":"https://login.microsoftonline.com/error?code=700016"}
Not sure what error you will see if Itreq_Appeon.ClientSecret is correct. Please adjust it to the correct one and check the response body.
ring ls_tenant_id = "450da9d8-2bd5-4662-aa74-c622350537e5" // Directory (tenant) ID
String ls_token
String ls_body
Integer li_rc
RESTClient Irc_RestClient
Irc_RestClient = CREATE RESTClient
//Sets the token parameters
TokenRequest Itreq_Appeon
Itreq_Appeon.TokenLocation = "https://login.microsoftonline.com/"+ls_tenant_id+"/oauth2/v2.0/token"
Itreq_Appeon.Method = "post"
Itreq_Appeon.GrantType = "client_credentials"
Itreq_Appeon.ClientId = "e3e65e1b-bcOf-4e02-b777-Oc94df554ed3"
Itreq_Appeon.ClientSecret = "unknown"
Itreq_Appeon.Scope = "https://graph.microsoft.com/.default"
li_rc = Irc_RestClient.GetOauthtoken( Itreq_Appeon, ls_token)
Regards, Logan