Skip to main content

If you are receiving the following 403 errors:

  • "message": "The used authentication method is not allowed on this route."
  • "message": "This route can only be accessed by anonymous users."

Then keep reading for how to resolve them.

 

Attempting to log in to a Drupal site using REST API and I had to battle a few head winds along the way.  What is worse, they were self imposed!

 

Attempting to authenticate

I was initially using the following to login in a user

method: post
url: https://example.com/user/login?_format=hal_json
headers:
Accept: application/hal+json

Authorization: basic

X-CSRF-Token: {string}

Content-Type: application/hal+json
body:
{
"name": "sarah",
"pass": "sa!ah"
}

 

Output:

Response: 403

"message": "The used authentication method is not allowed on this route."

Solution: If you are receiving this error, the issue you have is related to the headers.  Deactivate them.

 

Other responses

Response: 403

"message": "This route can only be accessed by anonymous users."

Solution: You have already logged in this user.  Log them out first, before attempting the login process again.