Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Deekshith's avatar

Laravel passpost machine to machine API authentication not working on domain change.

Hello All,

I have installed laravel passport and used machine to machine API authentication and it was working fine. and now i have changed the URL of the website and moved to different domain and i can generate the access token. and passed the newly generated token in authorization header in other routes and it is redirecting to login page. but if it try in old domain files it is working fine. after moving to new domain it is not working,

I have generated the token using below API,

https://www.example.com/oauth/token

Body

{
    "grant_type": "client_credentials",
    "client_id": "1",
    "scope": "*",
    "client_secret": "secret goes here"
}

And protected api is

https://www.example.com/api/page/example/2021/07

In header passing below ,

Authorization Bearer token_goes_here

It is working fine in my old domain. any help?

0 likes
0 replies

Please or to participate in this conversation.