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.



3 Replies
best response confirmed by vcima (Contributor)
You can try using Microsoft Authentication Library (MSAL). Please refer the below link

Hope it helps, please like it or mark it as a solution if it resolves ur clarification or issue
-Sudharsan K...

@Sudharsan K 


Hi!, I have solve the problem with this:


import {UserAgentApplication} from "msal";

config = {
auth: {
clientId: "client-id",
authority: ""

const myMSALObj = new UserAgentApplication(config);

accessTokenRequest = {
scopes: [""],
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
if (error.errorMessage.indexOf("interaction_required") !== -1) {


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: SHA256withRSA

Do you know what can I do to validate the Azure AD Token?