UNDERSTANDING Authentication & Authorization (OAuth, JWT, Sessions)

By (@idknows) · · Education & Learning

UNDERSTANDING Authentication & Authorization (OAuth, JWT, Sessions) - image 1

What is Authentication?

Authentication is the process of verifying the identity of a user or system. It ensures that the person or application trying to access a system is who they claim to be.
→ Example: Logging in with a username and password.

What is Authorization?

Authorization determines what an authenticated user is allowed to do within a system. It defines permissions and access levels.
→ Example: A normal user can view content, while an admin can add or delete content.

OAuth (Open Authorization)

→ A standard protocol for token-based authentication and authorization.
→ Allows users to log in using third-party providers like Google, Facebook, or GitHub.
→ Example: "Log in with Google" button on websites.

JWT (JSON Web Token)

→ A compact, secure token format used for authentication.
→ Contains encoded user information and is signed to ensure integrity.
→ Commonly used in stateless authentication, where the server doesn’t store session data.
→ Example: After logging in, the server issues a JWT that the client sends with every request.

Sessions

→ A method where the server stores user authentication data temporarily.
→ A session ID is stored in the client’s browser (cookie) and mapped to server-side data.
→ Example: Traditional web apps where a user stays logged in until the session expires or they log out.

Key Differences

→ OAuth: Delegates authentication to external providers.
→ JWT: Stateless authentication with tokens stored on the client.
→ Sessions: Stateful authentication with data stored on the server.

Real-World Examples

→ OAuth: Logging into Spotify using Facebook or Google.
→ JWT: APIs where clients authenticate using tokens.
→ Sessions: Classic PHP or Node.js web apps with login systems.

I Hope you find this helpful, Check Image for better understanding

Comments (7)

  1. Gordon ·

    Great breakdown. A lot of beginners mix up authentication and authorization, but they solve two very different problems.

  2. Joshua ·

    Simple way to remember: authentication answers who you are, authorization answers what you’re allowed to do.

  3. Lydia ·

    OAuth is one of those things most users interact with daily without realizing it. “Login with Google” is everywhere now.

  4. Lateef ·

    Most modern stacks actually combine these approaches. For example OAuth for login, then JWT for API access.

  5. Toney ·

    Auth systems seem simple at first, but once you deal with refresh tokens, expiration, and permissions, it gets interesting fast.

  6. The devquee ·

    Another key point with JWT is that it’s stateless, which makes scaling systems easier since the server doesn’t need session storage.

  7. Logan ·

    This is a good foundation for anyone building web apps. Understanding auth early saves a lot of headaches later.

17 likes · 7 comments · 3 views

Explore more on Prompted