Skip to content

Auth with Cloud Run Service Account? #3623

Closed

Description

@noahpodgurski

I can do local auth with the below code using my service account credentials. Set in .env as GOOGLE_APPLICATION_CREDENTIALS=./service-account-key.json

try {
    const auth = new google.auth.GoogleAuth({
      scopes: SCOPES,
      clientOptions: {
        subject: "user@email.com",
      },
    });
    const gmail = google.gmail({ version: "v1", auth });
    return gmail;
  } catch (e) {
    console.error(e);
    return null;
  }

But I'm trying to figure out how to get this working on Cloud Run using the service account on there.. I assumed the auth stuff would be passed in automatically, which doesn't seem right, but also couldn't find any documentation to show otherwise. Has anyone done this before? Any alternatives I can try here?

Activity

  1. sofisl commented on Feb 11, 2025

    @sofisl
    Contributor

    There's a number of different ways to authenticate to Cloud Run, please read the documentation. Moving this to Q&A.

  2. locked and limited conversation to collaborators on Feb 11, 2025
  3. converted this issue into a discussion #3624 on Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions