@Bbommel: Danke.
Damit es nicht untergeht im Text...
Lösung:
Fehlermeldung richtig lesen. Es war genau das was die Fehlemeldung sagte: "um den Wert des Clientgeheimnisses und nicht um die Clientgeheimnis-ID". Ich hatte den verkehrten herauskopiert.
Delphi-Quellcode:
conTokenURL = 'https://login.microsoftonline.com/%s/oauth2/v2.0/token';
conScopes = 'https://graph.microsoft.com/.default';
...
function TSecurity.GetAccessToken(Name: string): string;
var
Security: ISecurity;
OAuth: TclOAuth;
begin
Result := '';
if FSecurityDict.TryGetValue(Name, Security) then
begin
OAuth := TclOAuth.Create(nil);
try
OAuth.TokenUrl := Format(conTokenURL, [TToolsCrypt.Decrypt(Security.TenantID)]);
OAuth.ClientID := TToolsCrypt.Decrypt(Security.ClientID);
OAuth.ClientSecret := TToolsCrypt.Decrypt(Security.ClientSecret);
OAuth.Scope := conScopes;
OAuth.AuthorizationFlow := afClientCredentialsFlow;
OAuth.GetAuthorization;
Result := OAuth.Token.AccessToken;
finally
OAuth.Free;
end;
end;
end;