Course contentsShow
← System Design
Lesson 920 of 1,91924. Authentication and Authorization at ScaleFree lesson

OAuth2 Fundamentals and Use Cases

Understanding OAuth2 as a delegated authorization framework, not an authentication protocol.

OAuth2 Fundamentals and Use Cases

What you'll learn: Why OAuth2 is about delegated authorization, not authentication, and when to use it in system design.

What OAuth2 Actually Is

OAuth2 is a delegated authorization framework that allows applications to access resources on behalf of a user without handling their credentials. It's not an authentication protocol—it doesn't tell you who the user is, only that they've granted your app permission to do something.

Think of it like valet parking: you give the valet a special key that starts the car and opens the trunk, but not the glove compartment. You're delegating limited access without handing over your master key.

Authorization vs Authentication

This distinction matters in system design:

  • Authorization (OAuth2): "Can this app read my Google Drive files?"
  • Authentication: "Is this really Alice logging in?" (handled by OpenID Connect, built on OAuth2)

OAuth2 uses tokens (access tokens, refresh tokens) to represent delegated permissions, not user identity. A service receives a token and can access specific resources—but the token itself doesn't prove who authenticated.

Common Use Cases

Third-party integrations: Your app needs to post to users' Twitter accounts without storing their Twitter passwords.

Microservices authorization: Service A needs to call Service B on behalf of a user with specific scopes/permissions.

Mobile/SPA clients: Native apps and single-page applications that can't securely store credentials use OAuth2 flows to obtain tokens.

API access delegation: Users grant your analytics dashboard read-only access to their Stripe data.

System Design Impact

When designing authentication systems, use OAuth2 when you need permission delegation, not just user login. For authentication, you'll typically layer OpenID Connect on top.

Key Takeaway: OAuth2 is a delegated authorization framework for granting limited resource access without sharing credentials—it answers "what can you do?" not "who are you?"