pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
742 stars 302 forks source link

gettoken for another Azure APP using client id and pnpjs authenticated instance #3003

Closed mdissel closed 2 months ago

mdissel commented 2 months ago

What version of PnPjs library you are using

3.x

Minor Version Number

3.24.0

Target environment

All

Additional environment details

standalone html page

Question/Request

In a SPFX/webpart environment we can use this code to fetch an accesstoken for a different azure application: await (context.aadHttpClientFactory).getClient(clientId)

How can we do this when we have no spfx context and are authenticating in pnpjs like this:

    const sp = spfi("https://XXX.sharepoint.com/").using(SPBrowser(), MSAL(configuration, {
                scopes: ["https://XXX.sharepoint.com/.default"]
    }));
juliemturner commented 2 months ago

please check this documentation about authenticating in a browser outside of M365

https://pnp.github.io/pnpjs/concepts/auth-browser/

mdissel commented 2 months ago

Thanks, but I don't need a spfi instance. I need the bearer token

juliemturner commented 2 months ago

MSAL Broswer

mdissel commented 2 months ago

Thanks, so conclusion is, not possible with pnpjs and use the standard flow

github-actions[bot] commented 2 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.