I want to authenticate a service user with username and password against a On-Prem ADFS Server 2019. Then use the provided token to access an SharePoint-Online site in the context of the user. This should be the Single-Sign-On(SSO)-Flow. In my tries I get the "AADSTS50013: Assertion failed signature validation"-error.
The On-Prem app registration is configured like following:
Then I use the MSAL C# library to get the token like following:
var authority = "https://adfs.MYCOMPANY.net/adfs";
IPublicClientApplication app = PublicClientApplicationBuilder.Create(clientID)
.WithAdfsAuthority(authority)
.WithTenantId(tenantID)
.WithRedirectUri(RedirectUri)
.Build();
// convert password to SecureString
var securePassword = new SecureString();
foreach (char c in password) securePassword.AppendChar(c);
// Request Token
var result = app.AcquireTokenByUsernamePassword(scopes, username, securePassword).ExecuteAsync().Result;
var token = result?.AccessToken;
This will result in an "valid" token issued by the On-Prem ADFS (jwt.io screenshot):
The next Step is to access the SharePoint-Online resource with this token. But this will result in an error. For testing purpose I send an request against https://TENANT.sharepoint.com/_api/web/currentuser
with the header "Authorization=Bearer eyJ0...", but it fails with "Token contains invalid signature".
So I also tried converting the SAML-Token into a different JWT Token by sending a request to https://login.microsoftonline.com/7fc3a154-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/token
. I created a separate app registration in Azure for this request, but I couldn't enable SSO on the app registration like described here: https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso. So the following request still gives me an "AADSTS50013: Assertion failed signature validation".
My thoughts were, that the On-Prem AD is synchronized with the Azure AD. But the error looks like I need to add an additional Sign-Certificate to the Azure AD.
- Do I need to configure this certificate separately in Azure?
- Or do I need to convert this Saml-Token in a different one?