Is it possible to silently, completely without user interaction, acquire access token from login.microsoftonline.com, to authenticate web api running on-premise? I have registered an app in Azure portal. In the sharepoint site there is a js script which is using msal.js.
My msalConfig.js looks like this:
const msalConfig = {
auth: {
clientId: "my_client_id",
authority: "https://login.microsoftonline.com/my_tenant_id",
redirectUri: "my_redirect_uri"
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: false
}
};
const msalInstance = new PublicClientApplication(msalConfig);
And in the auth.js I am calling:
await msalInstance.ssoSilent(silentRequest);
But in this line I am receiving such error:
InteractionRequiredAuthError: login_required: AADSTS50058: A silent sign-in request was sent but no user is signed in.
Why is this? I am already logged into Sharepoint online in O365 (this site and scripts are hosted on Sharepoint). Is it possible to overcome it somehow?