Thank you for posting this in Microsoft Q&A.
I understand that you want to Authenticate to Microsoft Entra Application Proxy with SharePoint session.
The "InvalidTokenRetry" error message suggests that there is an issue with the authentication token that is being used to access the API.
To authenticate yourself to the application proxy using only the session you have in SharePoint, you can try using the MSAL.js library to obtain an access token for your API. MSAL.js is a JavaScript library that enables you to authenticate users and acquire tokens to access protected APIs.
Here are the general steps you can follow to use MSAL.js to obtain an access token for your API:
- Register your web API in Azure AD and obtain the client ID and tenant ID.
- Configure your web API to accept tokens issued by Azure AD.
- Register your SPFx web part in Azure AD and obtain the client ID.
- Configure your SPFx web part to request permissions to access your web API.
- Use MSAL.js to obtain an access token for your web API.
- Include the access token in the Authorization header of your fetch () request to your web API.
For your reference: https://github.com/AzureAD/microsoft-authentication-library-for-js
Hope this helps. Do let us know if you any further queries.
Thanks,
Navya.