1
votes

I've setup Laravel to use a custom 'SESSION_DOMAIN' and 'SANCTUM_STATEFUL_DOMAINS'. However I can't use Postman to login. What I did:

  • make GET request to '/sanctum/csrf-cookie'- save XSRF cookie value in an environment variable: xsrfToken
  • added header X-XSRF-TOKEN with the value being {{xsrfToken}}

Every time I make the post request I get:"Illuminate\Contracts\Encryption\DecryptException: The payload is invalid. in file ~/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php on line 195" And if I try it without the X-XSRF-TOKEN header I get a 419 Page Expired error. Anyone came across this problem? There seems to be no answer to my question yet when google searching.

1
try make session driver to cookie in .env fileTEFO
@TEFO Could you elaborate why that could fix the problem?Ezrab_
because you wanna use cookies but the default is file, but its hard to make it work in postman.TEFO
@TEFO Hmm yeah, but why wouldn't it be specified in the docs?Ezrab_
it is specified in the docs laravel.com/docs/7.x/sanctum#spa-authentication . as you can see said Sanctum uses Laravel's built-in cookie based session authentication servicesTEFO

1 Answers

-2
votes

The request you are sending to server like

POST 127.0.0.1:8000/login

and the pre-request url should match