SharePoint / SharePoint/sp-dev-docs
SPFX + Service Bus using SPFX AAD Token
@Ashlesha-MSFT is already working on this.
Since Sep 5, 2025.
- Dominant language
- PowerShell
- Stars
- 1.4k
- Forks
- 1.1k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 12
Description
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- 💥 Internet Explorer
- 💥 Microsoft Edge
- 💥 Google Chrome
- 💥 FireFox
- 💥 Safari
- mobile (iOS/iPadOS)
- mobile (Android)
- not applicable
- other (enter in the "Additional environment details" area below)
Additional environment details
- browser version latest
- SPFx version 1.21.1
- Node.js version 22
- etc
Issue description
In the SPFX it's possible to make HTTP requests to Azure using AadHttpClient.post / get.
But sometimes it fails to get the access token inside of these post / get methods with error "Error: Token request previously failed".
To avoid this I currently getting token (from context.aadTokenProviderFactory.getTokenProvider() + then getToken => which returns the token string) and make the usual JS fetch request with this token.
Getting token is secured with the retry and w/o cache to avoid the error above.
Obviously I try to avoid send connection string or other credentials to the frontend except of the Entra ID token.
Questions:
- Is there a way to use AadHttpClient.post / get but with possibility to request a new token if "Error: Token request previously failed" ?
- Since it's used for Service Bus ideally would be using their native library, but during the tests seems it's impossible to implement TokenCredential with SPFX AAD Token, maybe because it lacks other props from accesstoken, is there a way in SPFX getting these? (nuances if service bus lib is working at all in the browser is another topic, rather not) Preferrably in a form of TokenCredential, but not nesessarily.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.