🖥️ Week 02, Day 03 - Lecture

API Authentication Patterns

Author

Dr Jon Cardoso-Silva

Last updated

24 July 2025

🥅 Learning Objectives

By the end of this session, you should be able to: i) Understand common API authentication methods (API keys, Basic Auth, Bearer tokens, OAuth 2.0). ii) Use API params to control and filter data requests. iii) Implement secure credential management using .env files. iv) Apply authentication patterns to collect data from the Reddit API. v) Handle nested JSON responses and convert them to pandas DataFrames. vi) Recognise when different authentication methods are appropriate for different APIs.

ME204 course icon

Welcome! Today we’re moving from public APIs to authenticated ones—a key skill for accessing richer data sources.

We’ll use a hands-on approach: learn security principles, set up Reddit credentials together, then understand the authentication patterns you just used.

⏰ Date and Time: Wednesday, 23 July 2025 | 10.00am - 1.00pm 📍 Location: CKK.2.06 (see LSE’s 🗺️ campus map)

🗣️ Today’s Plan

  • 📚 Part 1: Security & API Foundations (50 minutes) REST APIs, HTTP headers, security principles, and why credentials matter.

  • 🛠️ Part 2: Reddit Setup Together (45 minutes)
    Follow along: create Reddit credentials, test authentication, secure your .env file.

  • 🎓 Part 3: Understanding What We Just Did (25 minutes) API Keys vs Basic Auth vs Bearer Tokens vs OAuth 2.0—and why Reddit uses Bearer tokens.

🎬 Lecture Slides

Use your keyboard arrows to move through the slides below. You can also view them in fullscreen.

Prefer a PDF? Download the slides here:

(Sometimes the PDF export is a bit buggy and some text may appear with different formatting.)

📓 Lecture Notebook

We’ll switch to hands-on coding during Part 2. Download the notebook here:

Save it to your me204-study-notes repository. You should also see it on Nuvolos.

After the Lecture

This afternoon: pagination—collecting large datasets by making multiple API requests. Since you’ll have Reddit credentials set up, we can focus entirely on the pagination logic.

💻 Today’s Lab

Mastering API Pagination.

➡️ Go to Lab Instructions

Questions?

➡️ Ask on Slack

🔗 Extra Resources: Reddit API

Official and community resources.