Blog

Who sets the OAuth callback URL when an agent puts your app online?

Google sign-in sends the person back to an address the app registered in advance. Put the app online and that address changes, which is where most sign-in trouble starts. Here is what the callback is, who sets it when a coding agent sends the app to Tofu, and how to read the error when the two addresses disagree.

Updated

The Sign-in page of a sample app in the Tofu dashboard: Google sign-in is on, with a note on whose name Google's window shows.
A sample app's Sign-in page: Google sign-in is on, and the note says Google's window shows Tofu's name, not the app's.

The short answer

A Google sign-in is a round trip. The app sends the person to Google with the client it was given and an address to come back to. Google checks that address against what the client registered, shows the consent screen, and sends the person back there with a code. The app then exchanges the code for a session.

The address to come back to is the callback. When a coding agent builds an app on your laptop, that address is usually localhost. When the agent puts the app online, the address becomes the app's public one, and the client has to know it. If the client still holds the old address, Google refuses the round trip and the person sees a redirect error instead of a sign-in.

What the callback is

  • The client. A Google client is an identity issued to one app. It carries the app's return address allow-list.
  • The callback. The return address, usually a path on the app such as /auth/callback. It has to match the client exactly, including the host and the scheme.
  • The code. Google puts a short-lived code in the return address. The app's server exchanges it for tokens; the code is not a session by itself.

Who sets it when an agent sends the app

Tofu takes one of two routes, and the callback belongs to a different place in each.

The routeWhose client Google seesThe callback it returns to
The app uses Tofu's sign-in entry pointTofu's connectionTofu's address, which hands the person back with a session in the app's database
The app uses its own sign-in serviceThe app's own service, which Tofu can configure after you approveThe app's own address, which has to match the client

With the first route, the sign-in guide shows what the app's Google button calls. Tofu owns the client and the callback, so the app's address can change without touching the Google side. With the second, the app's address is part of the client: Tofu can set it when it configures the service, and it has to be set again when the address changes.

Either way, the app's own code reads the session and decides what the person may see. The callback only gets the person back; it does not decide anything.

The Sign-in page of a sample app in the Tofu dashboard, listing Google and email with a password as the ways people sign in.
A sample app's Sign-in page: the two ways people can sign in, Google and email with a password.

Why the addresses stop matching

The three usual causes, in the order they happen:

  1. The app moved.

    It was built at localhost and put online at a public address; the client still holds the local one.

  2. The address is close but not equal.

    A trailing slash, http where the client has https, or a path that differs by a segment. Google compares the whole string.

  3. The client belongs to another app.

    Two apps on one machine can share a client by accident, and then one of their addresses is not on the list.

Google reports the first two with the same message, and it names the address it was given. Compare that address with the client's list character by character before changing anything else.

What the agent needs to know

  • The app's public address, before it writes the button. An agent that hardcodes localhost writes the wrong callback into the app.
  • Where the callback is handled. The route that receives the code has to exist in the app's server code; a client-only app has nowhere to exchange the code.
  • Which route the app takes. Tofu's entry point or the app's own service: the app's button calls a different address in each.

A prompt that says where the app will live, and which sign-in service it uses, gets a build that works at the public address the first time.

What Tofu does not do

  • Configure your own Google Cloud project. Tofu's connection and the app's own service are configured from the dashboard or by a coding agent; a client you made yourself stays yours.

  • Sign people in without the app's code. The button, the callback route and the check of the session are the app's.

  • Limit sign-in to Google and email. Those are the two the app's Sign-in page configures; anything else needs its own service.

Questions

What is an OAuth callback URL?

It is the address Google returns a person to after they approve the sign-in. The app's client registers it in advance, and Google refuses a return to any other address.

Why do I get a redirect error after the app goes online?

Almost always because the app's address changed and the client still has the old one. The error names the address it was given; compare it with the client's list.

Do I need a Google Cloud project?

Not with Tofu's sign-in entry point, and not with the app's own service that Tofu configures. A project of your own is for a client you control yourself.

Can the app use my own domain?

Yes. Register the domain's callback address on the client, then connect the domain; the domain guide covers the move. The order matters: the callback follows the address.

Whose account does the person sign in with?

Their own Google account. The app gets a session for that person in its own database, and Google's consent screen shows the name of whoever owns the client: Tofu's, or your app's when it has one of its own.