Skip to content
RED SAGSkills
easyBackend Developer interview question

What is the difference between authentication and authorization? How would you implement both in an API?

What the interviewer wants to hear

  • Authentication verifies who the user is
  • Authorization decides what the user is allowed to do
  • Sessions or tokens (JWT) for authentication; hashed passwords
  • Role-based or permission checks on every protected endpoint, done on the server
  • Correct 401 vs 403 responses

Model answer

Authentication answers who you are; authorization answers what you can do. For authentication, the user logs in with email and password, I check the password against a bcrypt or Argon2 hash, and then issue either a session cookie (HttpOnly, Secure) or a short-lived JWT with a refresh token. Middleware validates this on each request and attaches the user to the request. If it is missing or invalid, I return 401. For authorization, I check permissions on the server for every protected action, for example role-based access where only admins can delete users, plus ownership checks so a user can edit only their own posts. If the user is known but not allowed, I return 403. I never trust the frontend to hide buttons as the only protection.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Backend Developer questions