Send session cookie in response to passport API request
I am building an API on laravel and am using the Passport package to manage the authentication. One element of this project is a proxy to another webserver. These proxy'd pages will have their own links and AJAX style requests that will need to hit and proceed through the proxy.
Since the proxy'd pages are making their own requests, I can't tack on the Authorization header to authenticate the subsequent requests with the API. My thought would be to put the proxy route on the 'web' guard and use cookies to authenticate the proxy requests since the browser will automagically send the cookies with each request that is made. However, I need the API to return a cookie for the browser to store and use.
I have tried a couple things without much luck. Mainly just causing the Auth class to login a user, but it doesn't seem to do anything (probably because it already thinks the user is logged in due to the bearer token in the request). I have also tried adding in the 'web' guard for this call to Auth to see if that would do it, and it didn't.
How can I have an API route authenticated with Passport, return a cookie to authenticate subsequent browser requests through the default 'session' web guard?
I am on Laravel 7.
As a backup, I have considered researching a way to simply call a route on the 'web' guard from an API controller. This route on the web guard would return the cookie and subsequently (hopefully) be returned by the original API request. What would be the best way to try this if it came to it?
Thanks
Please or to participate in this conversation.