security-course

Security, Privacy, and Consumer Protection

View the Project on GitHub noise-lab/security-course

OAuth in Action

1. Overview

Every time you click “Sign in with Google” or connect a third-party app to Slack, you’re using OAuth 2.0. Instead of sharing your password with every service, OAuth lets you delegate limited access through tokens. It’s the modern standard for letting apps talk to each other on your behalf — without giving away the keys to your account.

In this activity, you’ll see OAuth in action twice: first by watching a live demo of connecting a third-party app, and then by running through a hands-on OAuth implementation to see exactly how the authorization flow works under the hood.


2. Learning Objectives

By the end of this session, you should be able to:


3. Activity

Step 1: Watch OAuth in the Wild

Your instructor will demonstrate connecting a third-party app to a service (e.g., adding an app to Slack, connecting GitHub to a tool, or linking a calendar app).

As you watch, answer:

Think about:

Step 2: Get the OAuth Demo Running

Clone the demo repository and follow the setup instructions:

git clone https://github.com/patrickbucher/oauth2-demo.git
cd oauth2-demo

Read the README to understand the architecture. The demo has three servers:

Start all three servers according to the README instructions.

Step 3: Walk Through the Authorization Flow

Open http://localhost:9000 in your browser and request access to the gossip.

Watch what happens:

  1. You get redirected to the authorization server. Look at the URL — what parameters are included? What is client_id? What is state for?

  2. Log in and authorize the client (use the credentials from the README).

  3. You get redirected back to the client. Look at the URL again — what changed? Do you see an authorization code?

  4. The client now displays the gossip. Behind the scenes, it exchanged the authorization code for an access token and used that token to fetch the data.

Open your browser’s Developer Tools (Network tab) and repeat the flow. Try to identify:

Step 4: Explore the Code

Open the source code and find where these things happen:

Look at how tokens are created. Are they random strings, or do they contain information (like JWTs)?

Step 5 (Optional): Break Things

Try these experiments to see what security properties OAuth has:


4. Discussion

Let’s talk about what you learned:

Think about the design:

We’ll wrap up by discussing when you’d use OAuth vs. other approaches — and what additional protocols (like OpenID Connect) build on top of it.