Serksa
All Concepts
Security

OAuth 2.0

1

What is it?

<strong>OAuth 2.0</strong> is an authorization framework that lets users grant third-party apps access to their data without sharing passwords. It's how 'Sign in with Google' works.

2

Think of it like...

The Hotel Key Card Analogy

Hotels don't give you the master key. They give you a key card with limited access (your room, pool, gym). OAuth tokens work the sameβ€”limited, revocable access.

🏨

Hotel (Resource Owner)

Your data

🎫

Key Card (Access Token)

Limited access

πŸšͺ

Room (Protected Resource)

What you're accessing

3

Visual Flow

πŸ‘€User

Wants to Authorize

β†’
πŸ”OAuth Provider

Google/GitHub

β†’
🎫Access Token

Granted to App

4

Where you see it

1

User clicks 'Sign in with Google'

Redirected to Google's login

2

User authorizes app

Grants permission to access email, profile

3

Google returns authorization code

Temporary code sent to your app

4

Exchange code for token

Your app trades code for access token

5

Access user data

Use token to call Google APIs

5

Common Mistake

❌

Wrong

"OAuth is for authentication"

βœ…

Correct

<strong>OAuth is for authorization, not authentication</strong>. It grants access to resources, not identity verification. Use OpenID Connect (built on OAuth) for authentication.

πŸ’‘ Real-World Example

Grammarly accessing Google Docs:

1

You click 'Connect Google Docs' in Grammarly

2

Google asks: 'Allow Grammarly to read/edit your docs?'

3

You approve β†’ Grammarly gets access token

4

Grammarly can now check grammar in your docs

5

You can revoke access anytime in Google settings