Skip to content
Justin Digs Data
Justin Digs Data
  • Home
  • Nerd Library
Justin Digs Data
Google API Gateway Logo

API Key Authentication with Google Cloud API Gateway and Cloud Run

Posted on February 10, 2024February 15, 2024 By Justin

Table of Contents

Toggle
  • Introduction
      • WARNING
  • Basic Steps
  • Prerequisites
  • Google Cloud Setup
    • Enable Needed Google Cloud Services
      • Console Method
      • Command Line Method
    • Create a Google Cloud Service Account
      • Console Method
      • Command Line Method
  • Backend API Creation
    • Create a simple Python-based API
      • main.py
      • requirements.txt
      • Dockerfile
      • start.sh
    • Deploy Code as a Docker Container to Cloud Run
    • Testing
    • Reenable Authentication
    • Grant Service Account Permissions
  • API Gateway Setup
    • Create API Gateway API
    • Testing Your API
      • Cloud Run URL
      • API Gateway URL
      • GET Tests
      • POST Tests
  • Conclusion

Basic Steps

This tutorial steps through an end-to-end walkthrough, including:

  1. Google Cloud Setup
    • Enable Needed Google Cloud Services
    • Create a Google Cloud Service Account
  2. Backend API Creation
    • Create a simple Python-based API
    • Deploy Code as a Docker Container to Cloud Run
  3. API Gateway Setup
    • Create an API Gateway API
    • Create an API Gateway Config
    • Create an API Gateway
    • Enable the API Gateway API
    • Creating an API Key
    • Test Your API

Depending on your starting point, you might be able to skip several of these steps altogether. For example, if you already have an API deployed as a Cloud Run service, you can skip the Backend API Creation part.

But because we need all of those pieces in order to demonstrate the end-to-end process, this tutorial includes a few extra steps to deploy a very simple Cloud Run service that serves up a couple basic endpoints: one that handles a simple GET request that just returns “Hello, World!”, another that listens for a POST and returns the sum of two numbers.

Prerequisites

The first four of these are only really needed for creating the simple Cloud Run service mentioned above. Again, if you already have a backend service deployed and/or you’re comfortable with that part, feel free to skip ’em.

If you want to follow along exactly, you’ll need the:

  1. Backend API Development
    • Python (and a few libraries we’ll install later)
    • VS Code
    • The Cloud Code for VS Code extension
    • Docker
  2. API Gateway
    • A Google Cloud account
    • A Google Cloud project
    • The Google Command Line Interface (gcloud CLI)

The installation and configuration of each of those is out-of-scope for this post. And frankly, if you need a hand with that part of the process, you might not be quite ready for the rest of this yet.

Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Backend Stuff APICloud RunGCPPythonTutorial

Post navigation

Next post

Categories

  • AI
  • Backend Stuff

Recent Posts

  • An LLM’s Blog Post about Why You Shouldn’t Use LLMs to Write Blog Posts
  • API Key Authentication with Google Cloud API Gateway and Cloud Run

Archives

  • February 2024
©2026 Justin Digs Data | WordPress Theme by SuperbThemes