How to reproduce this code typical in spfx: aadTokenProviderFactory.getTokenProvider

I am interested in obtaining a token like we do in SPFX:
const provider: AadTokenProvider = await this.context.aadTokenProviderFactory.getTokenProvider();
const token: string = await provider.getToken("https://graph.microsoft.com", true);

The service is just an example, it could be an app azure id.

How could I do this from Plumsail code.

Thx.

Hello @Miguel,

Yes, SPFx context is available in JS-editor of Plumsail Forms, the variable name is spfxContext.

Here is how the SPFx graph client can be obtained in code:

var graph = await spfxContext.msGraphClientFactory.getClient('3');

Please learn more in Use the MSGraphClientV3 to connect to Microsoft Graph post.

And if i want to connect to another service?? not graph?
const provider: AadTokenProvider = await this.context.aadTokenProviderFactory.getTokenProvider();
const token: string = await provider.getToken("https://service.flow.microsoft.com/", true);

@Miguel,

You can use the code form this article: Connect to Azure AD-secured APIs in SharePoint Framework solutions.

But instead of this.context, use spfxContext in JS-editor of Plumsail Forms.

1 Like