Websites · Glossary

What is OAuth?

OAuth 2.0 is an authorisation framework, defined in RFC 6749, that lets an app get limited access to an account on another service without seeing the person's password. The person approves access on the service's own page, and the app receives a token. OpenID Connect builds on OAuth to also say who the person is, which powers Sign in with Google.

When a site shows Sign in with Google, it is using OAuth and OpenID Connect. The person never types their Google password into the site; Google asks them, then hands the site a token.

· Co-founder

4 min read · Published

The four OAuth roles in a Sign in with Google flow
RoleIn OAuth termsIn Sign in with Google
Resource ownerThe person who owns the accountThe visitor with a Google account
ClientThe app asking for accessYour website or app
Authorisation serverIssues tokens after the person approvesGoogle's sign in and consent pages
Resource serverHolds the data the token unlocksGoogle's APIs, such as the profile endpoint

What it is

Before OAuth, an app that wanted to read your calendar or contacts often asked for your password, which gave it full access and no way to revoke it. OAuth 2.0 replaced that with tokens. The person approves a specific scope of access on the provider's page, the provider issues an access token to the app, and the app uses it until it expires or the person revokes it. OAuth itself only grants access. OpenID Connect, a layer on top, adds an ID token that tells the app who signed in, with a stable user identifier and, if requested, an email address and name.

How the flow works

The common flow for websites is the authorisation code flow. The site redirects the person to the provider with its client id, the scopes it wants, a redirect address and a random state value. The person signs in and approves. The provider sends them back to the redirect address with a short lived code. The site's server exchanges that code, with its client secret, for tokens. Apps that cannot keep a secret, such as phone apps and single page apps, add PKCE, defined in RFC 7636, so a stolen code is useless. Redirect addresses must be registered with the provider in advance, which is why sign in can work on one address and fail on another.

When it matters

For a small business site, OAuth matters as social sign in. Many visitors prefer one tap with Google to inventing another password, and the site receives a verified email address. It also matters when connecting the business's own tools, such as letting a site post to a calendar, where the business owner approves access once. It is not needed for a site with no accounts, and it does not replace a password option for visitors who do not want to link their Google account.

Common mistakes

Treating an access token as proof of identity instead of validating the ID token. Skipping the state parameter, which opens the door to cross site request forgery. Putting the client secret in browser or app code. Registering broad redirect patterns that an attacker could abuse. Asking for more scopes than needed, which scares people off at the consent screen. Forgetting that Google requires an app to be verified before some scopes are shown to the public. And linking accounts by email address alone without checking the provider verified the email.

Where it shows up in OneCraft

Visitor login on OneCraft sites is email and password through Supabase Auth with a password reset, plus Google sign in through OneCraft's broker, which works on the published site and on the installed app. Sign in belongs to the site's own database, set up by the agent when a capability needs data, with row level security on every table. The agent checks each new table as an anonymous visitor and as a signed in person before a generation step can finish.

Questions people ask

Is OAuth the same as single sign on?

Not exactly. Single sign on is the experience of signing in once and reaching several apps. OAuth is a framework for granting access, and OpenID Connect on top of it is one of the standard ways to build single sign on. SAML is another, common in large organisations.

Is Sign in with Google safe for my visitors?

Yes, when implemented correctly. The visitor's password stays with Google, Google can apply its own two step verification and suspicious sign in checks, and the site receives only the scopes requested. The visitor can remove the site's access from their Google account settings at any time.

What is the difference between OAuth and OpenID Connect?

OAuth 2.0 answers what an app may access, using access tokens. OpenID Connect answers who the person is, adding an ID token with their identity. Sign in with Google uses both: OpenID Connect to identify the visitor, and OAuth scopes if the site also needs data such as their profile picture.

Why does Google sign in fail on my preview address?

Google only returns visitors to redirect addresses registered for the app. A preview, staging or local address that is not on the list is refused with a redirect mismatch error. Production addresses are registered; temporary addresses often are not, which is why sign in can fail there.

Do I still need passwords if I offer Google sign in?

Usually yes. Not every visitor has or wants a Google account, some prefer not to link accounts, and some workplaces block social sign in. Offering email and password beside Google keeps everyone able to sign in, with one account per email address.

Make one with websites

The button opens the generator with this use case already described. Change the wording to match your own.

Create a website with OneCraft

Related questions

Sources

Written and checked by the OneCraft team. Last checked .