Forum Discussion
How can I auto-logged an user inside a Sharepoint Web Part?
I have a website "Play web". When I want to access into this site I have to login previously with user/pass. An authtentication module, handle this info and starts a communication with an Azure AD. If the user is validated properly using a callback the control is returned to the Play Web with the user logged. All these steps works fine.
Where is the problem?. One of our clients wants to embed this "Play web" inside his Sharepoint but he doesn't want relogin. He needs to use the Sharepoint context to autologged the user into the website.
Is there any way to do this?, Should have I setup something in Azure AD: Proxy, Function?
I'm stuck with this.
Regards
- Hi,
You can try using Microsoft Authentication Library (MSAL). Please refer the below link
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-overview
Hope it helps, please like it or mark it as a solution if it resolves ur clarification or issue
-Sudharsan K...
- Sudharsan KSteel ContributorHi,
You can try using Microsoft Authentication Library (MSAL). Please refer the below link
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-overview
Hope it helps, please like it or mark it as a solution if it resolves ur clarification or issue
-Sudharsan K...- vcimaBrass Contributor
Hi!, I have solve the problem with this:
import {UserAgentApplication} from "msal";
const config = {
auth: {
clientId: "client-id",
authority: "https://login.microsoftonline.com/tenant-id"
}
};
const myMSALObj = new UserAgentApplication(config);
let accessTokenRequest = {
scopes: ["user.read"],
loginHint: this.context.pageContext.user.loginName,
extraQueryParameters: {domain_hint: 'organizations'}
}
myMSALObj.acquireTokenSilent(accessTokenRequest).then(function(accessTokenResponse) {
// Acquire token silent success
// call API with token
let accessToken = accessTokenResponse.accessToken;
let scopes = accessTokenResponse.scopes;
}).catch(function (error) {
//Acquire token silent failure, and send an interactive request
console.log(error);
if (error.errorMessage.indexOf("interaction_required") !== -1) {
myMSALObj.acquireTokenRedirect(accessTokenRequest);
}
});- vcimaBrass Contributor
Hi @Sudharsan K
I have a problem with this accessToken. When I try to validate, something goes wrong: The Token's Signature resulted invalid when verified using the Algorithm: SHA256withRSADo you know what can I do to validate the Azure AD Token?
Regards