401 UnauthorizedError Missing or invalid credentials

System Information
  • Strapi Version: 4.14.4
  • Operating System: W10
  • Database: PG
  • Node Version: 18.13
  • NPM Version: 8.19.2
  • Yarn Version:

I’m getting error from strapi

{
    "data": null,
    "error": {
        "status": 401,
        "name": "UnauthorizedError",
        "message": "Missing or invalid credentials",
        "details": {}
    }
}

When I register new user, Strapi returns

{
    "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjQsImlhdCI6MTY5NzI0NDU1OCwibmJmIjoxNjk4NDU0MTU4LCJleHAiOjE2OTk4MzY1NTh9.brq-tvEFJyL_4oNUWWJGp-deZgF5KN8Z3y7uWLvJvpA",
    "user": {
        "id": 24,
        "username": "",
        "provider": "local",
        "confirmationToken": null,
        "confirmed": true,
        "blocked": false,
        "createdAt": "2023-10-14T00:49:05.328Z",
        "updatedAt": "2023-10-14T00:49:18.586Z",
        "phoneNumber": "+96336300",
        "email": "",
        "role": {
            "id": 1,
            "name": "Authenticated",
            "description": "Default role given to authenticated user.",
            "type": "authenticated",
            "createdAt": "2023-08-14T22:34:54.761Z",
            "updatedAt": "2023-10-14T00:40:59.158Z"
        }
    }
}

Then I use token to get authed access, but constantly get error.
Checkboxes are fine.

image

I tried wiping cache, deleting node_modules.
Will appreciate any help.

I found error. It was incorrect setting options in config file.

1 Like

Some problem here. Please can you tell me which options was wrong?
Thank you.

1 Like

Also same problem, could you explain how you fixed it?

I got this error when my user does not select any role, try to select role 1 in admin dashboard