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

leandrogrando's avatar

"The MAC is invalid." only in some cases. Even without changing APP_KEYS

Hello, I have a project in Laravel 7.0 with Passport 8.4. My project pages are generated by the blade and they also consume the API of the same project using Axios. API authentication takes place via Passport middleware that is added to all pages for use by Axios, as shown in the example https://laravel.com/docs/7.x/passport#consuming-your-api-with- javascript. What is happening, is that in some cases that I was unable to reproduce, the following error begins to appear:

{
    "class": "Illuminate\Contracts\Encryption\DecryptException",
    "message": "The MAC is invalid.",
    "code": 0,
    "file": "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:199",
    "trace": [
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:136",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/Guards/TokenGuard.php:282",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/Guards/TokenGuard.php:267",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/Guards/TokenGuard.php:234",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/Guards/TokenGuard.php:202",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/Guards/TokenGuard.php:96",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/passport/src/PassportServiceProvider.php:283",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php:58",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php:60",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:63",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php:42",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:687",
        "/var/www/sitebuilder-responsive-booking/vendor/laravel/framework/src/Illuminate/Routing/Router.php:662",
        "/var/www/sitebui

I know that the problem is not related to APP_KEYS because this project is in production and being used by several people, however, eventually the error "The mac is invalid" starts to appear, like, 20 times in a minute. There was a user complaining about not being able to do anything in the system (nothing that used ajax and the API) at the same time that the logs appeared, however, even so I couldn't reproduce the error

0 likes
0 replies

Please or to participate in this conversation.