Skip to content
Advertisement

Laravel Sanctum returns 500 when trying to access sanctum protected API

I am using Laravel 8.12 with PostgreSQL. I am trying to use Laravel Sanctum as authentication for my API. This is the schema for sanctum:

JavaScript

And this is my user table:

JavaScript

Now, when I try to send the token in headers, I get this error: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type uuid: "0" (SQL: select * from "personal_access_tokens" where "personal_access_tokens"."id" = 0 limit 1). As from my viewpoint, it looks as if this is the error with column type being uuid?

This is the command I use to make request:

JavaScript

Any help would be appreciated.

Advertisement

Answer

create a file with following contents.

JavaScript

and then I am calling this file PersonalAccessToken. And then on AppServiceProvider, do something like this.

am calling this file PersonalAccessToken. And then on AppServiceProvider, do something like this:

JavaScript

this will solve your problem

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement