Call different slim framework URL/REST API under the hood?

Let’s suppose I’ve two services:

  1. one for authentication purpose only -> This has /login endpoint
  2. second for other purpose -> This also has a /login endpoint, but I want to call service one’s /login endpoint under the hood.

Sample endpoints:

  1. Service # 1 POST http://service1.com/login (Request body has ‘email’ & ‘pass’)
  2. Service # 2 POST http://service2.com/login (should call service # 1’s /login by passing full request object, under the hood)

Ideally end user won’t be aware of service # 1 at all. This is the requirement.
Is this kind of structure possible?
If not what’s best I can do for this? Just simple redirection?

NOTE:- Both services are implemented using Slim Framework

Redirecting from service2.com to service1.com and then back to service2.com should be transparent. At most a user will see a notification in the status bar that data is being loaded from service1.com.

I didn’t know it was possible redirect a POST request, but apparantly it should work with a 307 status code. I haven’t checked though.

Instead of redirecting, you can also issue a POST request from service2 to service1 using cURL or guzzle. But if you need cookies to be set for the service1.com domain, you will have to redirect the user in some form.