Skip to content

SSO with Google Workspace

For: an app developer, or the Google Workspace admin of a customer, who connects the customer’s Google Workspace to an organization.

What it does: this page gives the console steps for OIDC, through a Google Cloud OAuth client, and for SAML, through a custom SAML app. Each field name is the name on the Google pages of the last table.

  • A verified domain of the organization, by the steps of Enterprise SSO.
  • A super administrator of the customer’s Google Workspace for SAML (Google help), or a Google Cloud project for OIDC.

Pick one kind. OIDC needs fewer values.

  1. In the Google Cloud console, open the Google Auth Platform “Clients” page.
  2. Select “CREATE CLIENT”, and pick the application type “Web application”.
  3. Copy the client ID and the client secret. Google shows the secret only after the create.
  4. Create the connection with these two values, as googleOidc below does.
  5. In “Authorized redirect URIs”, enter <baseURL><basePath>/sso/<connectionId>/callback.

The issuer is https://accounts.google.com. Any Google account can sign in to such a client. Core refuses each address outside the verified domains of the organization with sso_domain_mismatch. A redirect URI must use https.

  1. In the Google Admin console, go to “Apps” > “Web and mobile apps”.
  2. Select “Add App” > “Add custom SAML app”. Enter the app name.
  3. On “Google Identity Provider details”, copy the “SSO URL” and the “Entity ID”, and download the “Certificate”.
  4. Create the connection with these three values, as googleSaml below does.
  5. On “Service Provider Details”, enter the acsUrl of the connection in “ACS URL”.
  6. Enter the spEntityId of the connection in “Entity ID”.
  7. Set “Name ID format” to PERSISTENT.
  8. Under “Add mapping”, map the primary email to the app attribute email.
  9. Select “Finish”. Under “User access”, turn the app on for the people of the customer.

The “Name ID format” must be PERSISTENT. Core asks for the persistent format, and refuses any other NameID format. The default “Name ID” value is the primary email. So a change of the address gives the person a new subject. To avoid that, map an attribute that never changes, and name it in subjectAttribute of the connection. Then core reads the subject from that attribute, and the “Name ID format” may stay as it is.

Google signs the Assertion by default. Leave “Signed response” as it is: core verifies a signed Response too.

In step 3, you may also download the metadata file. Pass its text as idpMetadata in place of the three values.

The connection input of Google Workspace
import type { ConnectionInput } from "@authtempo/core";
/**
* A Google Cloud OAuth client of the type "Web application" as an OIDC
* connection. Any Google account can sign in to such a client, so core
* refuses each address outside the verified domains of the organization.
*/
export function googleOidc(input: {
organizationId: string;
clientId: string;
clientSecret: string;
}): ConnectionInput {
return {
organizationId: input.organizationId,
kind: "oidc",
label: "Sign in with Google",
issuer: "https://accounts.google.com",
clientId: input.clientId,
clientSecret: input.clientSecret,
};
}
/**
* A custom SAML app of Google Workspace as a SAML connection, from "Google
* Identity Provider details": the "SSO URL", the "Entity ID", and the
* certificate. Its "Download IDP metadata" file goes in `idpMetadata` in
* place of the three fields.
*/
export function googleSaml(input: {
organizationId: string;
ssoUrl: string;
entityId: string;
certificatePem: string;
}): ConnectionInput {
return {
organizationId: input.organizationId,
kind: "saml",
label: "Sign in with Google",
idpEntityId: input.entityId,
ssoUrl: input.ssoUrl,
certificates: [input.certificatePem],
// The app attribute that "Add mapping" maps from the primary email.
attributes: { email: "email", name: null },
};
}
The connection of each provider as a test
import { createAuth, type DnsTxtPort } from "@authtempo/core";
import { createTestIdp } from "@authtempo/core/testing";
import { describe, expect, it } from "vitest";
import { API, call, harness, signIn } from "../support/harness.ts";
import { entraOidc, entraSaml } from "./sso-entra.ts";
import { googleOidc, googleSaml } from "./sso-google.ts";
import { oktaOidc, oktaSaml } from "./sso-okta.ts";
const APP = { kind: "app", name: "admin-page" } as const;
/** An app with OIDC and SAML connections on, and one organization of an owner. */
async function setup() {
const h = harness();
const dns: DnsTxtPort[] = [{ name: "a", txt: async () => [] }];
const auth = createAuth({
baseURL: API,
trustedOrigins: [],
secret: h.secret,
storage: h.storage,
mail: h.mail,
organizations: {},
sso: { oidc: true, saml: true, dns },
});
const owner = await signIn(auth, h, "owner@owner.example");
const made = await call(
auth,
"POST",
"/auth/organizations/create",
{ slug: "acme", name: "Acme" },
{ cookie: owner },
);
const { organization } = (await made.json()) as { organization: { id: string } };
const sso = auth.api.sso;
if (!sso) throw new Error("sso is off");
return { sso, organizationId: organization.id };
}
describe("the connection of each provider", () => {
it("takes the OIDC values of Entra ID, Okta, and Google", async () => {
const { sso, organizationId } = await setup();
const inputs = [
entraOidc({
organizationId,
tenantId: "aaaabbbb-0000-cccc-1111-dddd2222eeee",
clientId: "client-1",
clientSecret: "secret-1",
}),
oktaOidc({
organizationId,
oktaDomain: "acme.okta.com",
clientId: "client-2",
clientSecret: "secret-2",
}),
googleOidc({ organizationId, clientId: "client-3", clientSecret: "secret-3" }),
];
const issuers: string[] = [];
const methods: string[] = [];
for (const input of inputs) {
const made = await sso.connections.create({ actor: APP, ...input });
if (!made.ok) throw new Error(`${made.code} ${made.message ?? ""}`);
issuers.push(made.value.oidc?.issuer ?? "");
methods.push(made.value.oidc?.tokenEndpointAuthMethod ?? "");
// No answer holds the client secret.
expect(JSON.stringify(made.value)).not.toContain("secret-");
}
expect(issuers).toEqual([
"https://login.microsoftonline.com/aaaabbbb-0000-cccc-1111-dddd2222eeee/v2.0",
"https://acme.okta.com",
"https://accounts.google.com",
]);
// Okta's default method is HTTP Basic; Entra ID and Google take the default of a connection.
expect(methods).toEqual(["client_secret_post", "client_secret_basic", "client_secret_post"]);
});
it("takes the SAML values of Entra ID, Okta, and Google, and answers the values for the provider", async () => {
const { sso, organizationId } = await setup();
const idp = await createTestIdp({ alg: "rsa" });
const inputs = [
entraSaml({
organizationId,
loginUrl: "https://login.microsoftonline.com/aaaabbbb-0000-cccc-1111-dddd2222eeee/saml2",
entraIdentifier: "https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/",
certificatePem: idp.certificatePem,
}),
oktaSaml({
organizationId,
ssoUrl: "https://acme.okta.com/app/acme/sso/saml",
issuer: "http://www.okta.com/exk1",
certificatePem: idp.certificatePem,
}),
googleSaml({
organizationId,
ssoUrl: "https://accounts.google.com/o/saml2/idp?idpid=C01",
entityId: "https://accounts.google.com/o/saml2?idpid=C01",
certificatePem: idp.certificatePem,
}),
];
for (const input of inputs) {
const made = await sso.connections.create({ actor: APP, ...input });
if (!made.ok) throw new Error(`${made.code} ${made.message ?? ""}`);
const id = made.value.id;
expect(made.value.saml?.attributes).toEqual({ email: "email", name: null });
// The two values that each admin console asks for.
expect(made.value.saml?.spEntityId).toBe(`${API}/auth/sso/${id}/metadata`);
expect(made.value.saml?.acsUrl).toBe(`${API}/auth/sso/${id}/acs`);
}
});
});
  • Core verifies the Assertion with the certificate of the connection, never with a key of the document.
  • A connection holds one or two certificates. When Google makes a new certificate, add it to certificates first, then remove the old one.
  • A change of the app in the Admin console can take up to 24 hours.
  • sso_failed: the log line names the step. audience means a wrong “Entity ID”. destination or subject_confirmation means a wrong “ACS URL”. address means no attribute email. subject means a “Name ID format” other than PERSISTENT.
  • sso_domain_mismatch: the address is outside the verified domains.
  • email_required: the ID token of an OIDC sign-in holds no address.
  • sso_not_configured: the connection is off, or the config does not turn its kind on.
  • invalid_body: the connection create refused a value. The message names the field.
Page Read (UTC) Updated on the page
Set up your own custom SAML app 2026-10-23 20:58 2026-10-22
OpenID Connect 2026-10-23 20:58 2026-06-15
Manage OAuth Clients 2026-10-23 20:58 not shown