Sobes.tech
Senior

What HTTP response codes do you know? How does 401 differ from 403?

sobes.tech AI

Answer from AI

Some common HTTP response codes:

  • 200 OK — request successfully processed
  • 201 Created — resource successfully created
  • 400 Bad Request — invalid request
  • 401 Unauthorized — authentication required
  • 403 Forbidden — access denied
  • 404 Not Found — resource not found
  • 500 Internal Server Error — internal server error

Difference between 401 and 403:

  • 401 Unauthorized means that the client is not authenticated or provided incorrect credentials. The server expects the client to authenticate first.

  • 403 Forbidden means that the client is authenticated but does not have permission to access the resource. The server understands who the client is but denies access.

Example:

If a user is not logged in and tries to access a protected resource — the server will return 401. If a user is logged in but does not have permission for that resource — the server will return 403.

What HTTP response codes do you know? How does 401… - sobes.tech