Search code examples
gmail-apigoogle-cloud-pubsubsupabase

Gmail API and PubSub: Hit external webhook with custom header?


I want to trigger a Supabase function whenever a new email arrives in Gmail.

If I understand Google's Instructions correctly, this needs to be done using Google's Pub/Sub service.

However, Supabase requires an authorization header to be sent with the POST request to the webhook, and while Pub/Sub allows for authorization, it only seems to support service accounts, and not just setting a simple Bearer token.

It seems like either polling or setting up a proxy webhook would be the only feasible options left—unless I'm missing a simpler way?

Thanks!


Solution

  • You can deploy the function to not require the auth headers by adding the --no-verify-jwt flag when deploying your functions.

    From the edge functions docs

    By default, Edge Functions require a valid JWT in the authorization header. This header is automatically set when invoking your function via a Supabase client library. If you want to use Edge Functions to handle webhooks (e.g. Stripe payment webhooks etc.), you need to pass the --no-verify-jwt flag when deploying your function.