Create an add-in for Excel for a listening server

From an Excel file, I want to call a bunch of APIs protected with Microsoft Entra ID. The multifactor authentication is enabled as explained in this Microsoft document. So, my idea is from an Excel spreadsheet to call the Entra ID
and access the data. Here is an easy schema.
Now, the Excel spreadsheet needs the authentication token to be added to the HTTP request as explained in this Microsoft document. Because the MFA is enabled, if I call the Entra ID for the login, I get an error because I have to be authenticated with MFA. Generally, when I test my APIs, for example from Swagger, I click on the Authentication button on the page, I am redirected to the Microsoft pages for the authentication, and, after the successful authentication, Microsoft callbacks to the Swagger page where I have the token.
I can't find a way from an Excel spreadsheet to do that. Also, I googled it, and I can't find a way to create a server that is listening on a specific port to receive the callback from the Microsoft pages.
Is there any solution for it?
One idea was to create an Excel add-in and implement a listening server on a specific port to receive the callback. I don't know what the limitations are and if it is possible to do something like that.