Skip to content
man glossary/oauth

glossary define oauth

Name

OAuth 2.0

An authorisation framework that lets an app act on someone's account through a scoped, revocable access token instead of their password.

Synopsis

OAuth, OAuth2, Delegated authorisation

Section

Security & identity

Level

practitioner

▍

Reviewed

Step through the Embedded Signup code exchange

9 / 9
  • Business adminin the browser
  • Your signup pageFacebook JS SDK
  • Metaauthorisation server
  • Your serverholds the app secret

Step 9 of 9Request

Your serverMeta

POST /{WABA_ID}/subscribed_apps

Sent with Authorization: Bearer {BUSINESS_TOKEN}.

  • Request — solid arrow — a call that expects an answer
  • Response — dashed arrow — the answer coming back
  • Event — dotted arrow — something happened and is pushed out
  • Async — double head — fire-and-forget, nobody waits
Four parties, one authorisation code: watch the code reach your page, your server swap it for a token using the app secret, and the token start working, without the password ever leaving Meta.

Step 9 of 9: Your server to Meta — POST /{WABA_ID}/subscribed_apps. Sent with Authorization: Bearer {BUSINESS_TOKEN}.

Description

What is OAuth 2.0?

OAuth 2.0 is the industry-standard framework for delegated authorisation, defined in RFC 6749. Instead of handing an app their password, a resource owner (a person or a business) approves a specific set of permissions, called scopes, and an authorisation server issues the app an Access Token limited to those scopes. The token can expire, be revoked and be inspected, so access stays bounded and reversible.

On the WhatsApp Business Platform, OAuth is the machinery behind Facebook Login for Business and Embedded Signup. A business owner logs in with Meta inside your page, picks or creates a WhatsApp Business Account and phone number, and approves scopes, which Meta calls API Permissions, such as whatsapp_business_management (WABA settings, phone numbers, templates) and whatsapp_business_messaging (sending and receiving). Your page receives a short-lived authorisation code; your server exchanges it at /oauth/access_token with your app ID and app secret, and Meta returns a Business Integration System User Access Token scoped to that customer's assets.

The core grant is the authorisation code flow: redirect to the authorisation server, the user consents, a code comes back, and the server swaps it for tokens over a back channel so the token never sits in a browser URL. RFC 9700, the OAuth 2.0 Security Best Current Practice published in January 2025, recommends PKCE for authorisation-code clients and retires the implicit and password grants. OAuth answers "what may this app do?", not "who is this person?"; that second question is what OpenID Connect adds on top.

Key takeaways

  • OAuth 2.0 lets one app act on another party's account through a scoped, revocable access token; the password is never shared.
  • Embedded Signup is an OAuth flow: the business approves scopes, your page gets a code, and your server swaps it for a token.
  • The Embedded Signup code has a time-to-live of 30 seconds, so exchange it on your server straight away.
  • WhatsApp integrations need whatsapp_business_management and whatsapp_business_messaging; request nothing you do not use.
  • OAuth grants access, not identity: use OpenID Connect when you need to know who signed in.

Mechanics

How does OAuth 2.0 work?

  1. step 1 — Configure the app and the login

    In your Meta app, set up Facebook Login for Business with a configuration (config_id) listing the permissions and asset types Embedded Signup will request, and add your page's domain to the allowed domains and valid OAuth redirect URIs.

  2. step 2 — Send the business to consent

    Your page calls FB.login with config_id, response_type: 'code' and override_default_response_type: true. The business logs in with Meta, selects or creates its WABA and number, and approves the scopes.

  3. step 3 — Receive the authorisation code

    The login callback returns authResponse.code, while a separate message event carries waba_id and phone_number_id. The code is valid for 30 seconds, so post it to your backend immediately.

  4. step 4 — Exchange the code on your server

    Your server calls GET /oauth/access_token with client_id, client_secret and code. The app secret never leaves the server, and the response carries the customer's business token.

  5. step 5 — Use, store and revoke

    Keep the token in a secrets vault keyed by WABA, use it to subscribe your app to the WABA and register the number, inspect it with debug_token, and treat a revoked or expired token as a prompt to reconnect.

Usage

OAuth 2.0 in code

// Embedded Signup is an OAuth authorisation-code flow run by the Facebook JS SDK.
FB.login((response) => {
const code = response.authResponse?.code; // time-to-live: 30 seconds
if (!code) return showError("Signup was cancelled");
fetch("/api/whatsapp/onboard", { // hand it to your server at once
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code }),
});
}, {
config_id: "{CONFIG_ID}", // Facebook Login for Business configuration
response_type: "code", // ask for a code, never a token, in the browser
override_default_response_type: true,
extras: { setup: {} },
});
// The WABA and phone number IDs arrive separately, as a message event.
window.addEventListener("message", (event) => {
if (!["https://www.facebook.com", "https://web.facebook.com"].includes(event.origin)) return;
try {
const msg = JSON.parse(event.data);
if (msg.type === "WA_EMBEDDED_SIGNUP" && msg.event === "FINISH") {
saveIds(msg.data.waba_id, msg.data.phone_number_id);
}
} catch { /* not an Embedded Signup message */ }
});

The browser only ever holds a 30-second code; the token is minted on your server.

Caveats

Common mistakes with OAuth 2.0

  • Exchanging the code in the browser

    The exchange needs your app secret, so doing it client-side hands the secret to every visitor. Post the code to your backend and exchange it there.

  • Missing the 30-second window

    Queuing the code behind other onboarding work or a slow API call lets it expire, and the business has to start again. Exchange first, then do everything else.

  • Requesting every scope just in case

    Extra permissions widen the blast radius of a leaked token and make the consent screen look alarming. Follow the Principle of Least Privilege: request only what the integration calls; business_management is rarely needed for messaging.

  • Treating OAuth as login

    An access token proves an app may act, not who the person is. If you need to sign people in to your own product, use OpenID Connect and validate an ID token.

  • Storing tokens like configuration

    Business tokens in source code or plain .env files end up in repositories and logs. Keep them in a secrets vault keyed by WABA, and plan how you will rotate or reissue them.

Why it matters

Why does OAuth 2.0 matter?

Before OAuth, connecting a partner to a business account meant sharing a login, which could not be scoped, audited or revoked without changing the password for everyone. With OAuth, a business can connect its WhatsApp number to a provider in minutes, see exactly which permissions it grants and withdraw them later from its business settings without touching anyone's credentials. For developers, it is why tokens exist at all, why they carry scopes and why a leaked token can be cut off without taking the whole account down.

Properties

OAuth 2.0: key facts and limits

Specification
RFC 6749 (2012); security BCP RFC 9700 (2025)
Main grant for web apps
Authorisation code, with PKCE
WhatsApp scopes
whatsapp_business_management, whatsapp_business_messaging
Embedded Signup code lifetime
30 seconds
Code exchange
GET /oauth/access_token, server-side
Token presented as
Authorization: Bearer {ACCESS_TOKEN}

Example

Example: Onboarding a Lucknow coaching institute

A messaging platform's sign-up page embeds the Meta login button. The admin of a Lucknow coaching institute clicks it, logs in with Meta, creates a WABA for the institute, verifies the institute's number and approves the two WhatsApp scopes. The page posts the returned code to the platform's backend, which exchanges it well inside the 30-second window, stores the resulting business token in its vault under the WABA ID, subscribes its app to that WABA's webhooks and registers the number. Months later the institute changes provider: it removes the platform's access in its business settings and the token stops working, without a password ever having been shared.

Notes

Best practices for OAuth 2.0

  • Log the waba_id, phone_number_id and granted scopes at onboarding, so support can see exactly what a customer approved.
  • Run debug_token on a schedule to catch revoked or narrowed tokens before sends fail.
  • Handle Error 190 (Access Token Invalid) as a reconnect prompt for the customer, not as a retryable error: the token has expired or been revoked.
  • Use one code path for first onboarding and for reconnection, so re-consent is as easy as sign-up.

Questions

OAuth 2.0 FAQs

Is OAuth the same as logging in with Facebook?
Not exactly. OAuth delegates permissions to an app; signing someone in also needs proof of identity, which OpenID Connect adds. Facebook Login for Business uses OAuth to grant your app access to a business's WhatsApp assets.
Which OAuth scopes does a WhatsApp integration need?
Usually whatsapp_business_management and whatsapp_business_messaging. The first covers WABA settings, phone numbers and templates; the second covers sending and receiving messages. Add business_management only if you manage the business portfolio itself.
Does the business share its Facebook password with the provider?
No. The business logs in with Meta directly and approves scopes; the provider receives only a token limited to those permissions, which the business can remove later from its business settings.
What is PKCE and do I need it?
PKCE (Proof Key for Code Exchange, RFC 7636) binds an authorisation code to the client that requested it, so an intercepted code is useless. RFC 9700 recommends it for authorisation-code clients, so use it in your own OAuth flows and mobile apps.

See WhatsApp API pricing

Reach customers on WhatsApp

Start a 7-day free trial of the official WhatsApp Business API — no card needed.