Forum Discussion
Programmatically add a user to the SharePoint UIL from Fabric after ACS retirement?
Hi MathieuSGA,
Thank you for reaching out to the Microsoft fabric community forum.
Your understanding of the UIL behavior is correct. SharePoint Person/Group fields still depend on the site’s User Information List, so users must exist in the UIL before those fields can be populated successfully. One important detail is that your current implementation uses Entra app-only with a client secret. Microsoft’s supported modern model for SharePoint Online app-only REST access is certificate-based authentication and client-secret app-only tokens are known to cause the Unsupported app only token error in SharePoint REST scenarios.
However, I could not find any official Microsoft documentation explicitly confirming whether /_api/web/ensureuser supports or rejects certificate-based Entra app-only authentication. Microsoft also does not provide a Graph API to preload users into the UIL and there is no documented way to bypass the UIL dependency using only UPN or Object ID. So, at this point, certificate-based Entra app-only auth is still worth testing against ensureuser, since it is the only remaining supported unattended model. If that still fails with Unsupported app only token, then there likely is no fully supported unattended UIL provisioning path remaining after ACS retirement.
In practice, the remaining reliable options are delegated bootstrap flows like Power Automate running in user context or having users access the SharePoint site once so they are automatically added to the UIL.
Please check below documentation for your reference:
Granting access using SharePoint App-Only | Microsoft Learn
AzureAd/Sahrepoint connexion - Invalid client secret error in Access token request with a certifica…
Granting access via Entra ID App-Only | Microsoft Learn
Accessing SharePoint using an application context, also known as app-only | Microsoft Learn
Hope this helps if you have any queries we are happy to assist you further.
Regards,
Community Support Team.
- MathieuSGA3 months agoAdvocate I
Sounds interesting/promising !
As for the steps ahead, would you happen to have more detailed step-by-step guide to how to:
- generate a credential in Azure
- be able to use it in a Fabric Notebook to generate/acquire a token that would allow us to call the `_api/web/ensureuser` with a successfull outcome
As for some additional context here are ...
... a printscreen of the Azure App config menu - could you confirm part of the job happens here ?... a snippet of code I found here to supposedly retrieve a certificate that would have been store in an Azure KeyVault Secret
import base64, msal from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.serialization import pkcs12, Encoding, PrivateFormat, NoEncryption # 1. Load credentials from Azure Key Vault kv_url = "https://your-keyvault.vault.azure.net" tenant_id = notebookutils.credentials.getSecret(kv_url, "sp-tenant-id") client_id = notebookutils.credentials.getSecret(kv_url, "sp-client-id") cert_pfx_b64 = notebookutils.credentials.getSecret(kv_url, "sp-certificate") # 2. Parse the PFX to extract what MSAL needs private_key, certificate, _ = pkcs12.load_key_and_certificates( base64.b64decode(cert_pfx_b64), password=None ) private_key_pem = private_key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption()).decode() thumbprint = certificate.fingerprint(hashes.SHA1()).hex().upper() # 3. Acquire an access token app = msal.ConfidentialClientApplication( client_id=client_id, client_credential={"private_key": private_key_pem, "thumbprint": thumbprint}, authority=f"https://login.microsoftonline.com/{tenant_id}" )
Would you happen to need any additional intel to help: I am available to provide them asap.- v-hjannapu3 months agoCommunity Support
Hi MathieuSGA,
Yes, the screenshot you shared shows the correct area in Azure where the certificate gets attached to the App Registration under the Certificates tab. Typically, the certificate itself is first generated externally (for example via PowerShell or Azure Key Vault) as a .cer + .pfx pair and then the public certificate is uploaded there. Your Fabric notebook approach is also aligned with the current MSAL + certificate + Key Vault pattern Microsoft recommends for modern SharePoint app-only authentication.
The general flow would be to generate a certificate, upload the public certificate to the App Registration, store the PFX securely in Key Vault, retrieve it from Fabric at runtime and then use MSAL certificate authentication instead of a client secret to acquire the SharePoint token.
That said, I would still treat this as a validation step specifically for /_api/web/ensureuser. Microsoft documents certificate-based Entra app-only authentication for SharePoint Online REST APIs generally, but I could not find clear documentation confirming that /_api/web/ensureuser specifically supports app-only execution. So, the setup itself looks correct, but ensureuser may (mostly not) still reject the token requiring delegated user context.
Hope it helps to resolve your issue.
Regards,
Community Support Team.- v-hjannapu2 months agoCommunity Support
Hi MathieuSGA,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.
Regards,
Community Support Team.