Skip to main content
Architecture Security AI
View as Markdown Suggest changes

How One App Authenticates to Three APIs

· Reading time: 20 min
How One App Authenticates to Three APIs

TL;DR

API keys, OAuth and JWT come up together whenever an API needs authentication, but they sit on three different layers. An API key is a credential: a long-lived secret sent with every request. OAuth 2.0 is a protocol for getting a credential: you trade a secret you hold for a short-lived access token with limited scopes, either as yourself (client credentials) or for a person who consented to it (authorization code). A JWT is a format a token can take: signed JSON the API can check without asking anyone. OAuth access tokens are often JWTs, which is why the three get mixed up. Signing people in is one more layer on top: OpenID Connect, run by an identity provider such as Keycloak, which is where single sign-on comes from. As the one calling an API, I need to know which credential it wants, how to get and renew it, and where to keep it.

One app, three systems

The running example is the invented Northstar Bank from my posts on support automation. Alex Carter writes in that their account is locked. To help, our app, the support automation, calls three systems:

  • the ticketing system, to open an escalation
  • the CRM, to look up Alex’s account and its security flag
  • the calendar of Alex’s personal advisor, to book a call with Alex.

Each wants a different credential, and the sections below go through them in that order.

Our app holds every credential, in a secrets store, and attaches the right one to each call. In an agent, this code sits behind the tools, so the model never sees a credential; that is a topic of its own.

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorOur codeTheir API

The running example as one map: one app, three systems, a different credential for each. Each section’s map highlights its part.

API keys: one secret, one header

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorStaticOur codeTheir API
Our appTicketingAPI key, once1On every call after thatKey in the header2Looks up the key3201: ticket opened4Same key until rotated

One handover, then one call per request. Nothing to fetch, nothing that expires.

The ticketing system issues the key once (1): whoever administers it generates one in its settings page, and it goes straight into our secrets store. From then on, every request to open a ticket carries it (2):

POST /v2/tickets HTTP/1.1
Host: api.ticketing.example.com
Authorization: Bearer tk_live_4f9a...e21c
Content-Type: application/json

{"subject": "Locked account, security flag set", "customer_id": "NSB01234", "priority": "high"}

Some APIs want it in a custom header (X-API-Key) or as the username of HTTP Basic auth; the docs say which. The server looks the key up (3) and opens the ticket (4). Nothing to fetch, nothing expires mid-conversation, and a curl with one header works. The costs come from the same simplicity:

  • It identifies an application, not a person. The ticket is created “by the integration”, whichever customer or advisor it concerns.
  • It lives until someone rotates it. A key leaked into a log or a Git commit keeps working until someone notices.
  • It is often all-or-nothing. Some platforms let you scope a key to read-only or one project; many don’t.
  • It goes in a header, never in the URL. Query strings end up in proxy logs and browser history.

Whether those costs matter depends on whom the call acts for.

Opening an escalation is something our app does as itself. Nobody has to authorize it, and a credential that identifies only the integration is exactly right.

Booking into an advisor’s calendar is different: the calendar belongs to a person, and the call should work only for advisors who consented. An API key identifies the application, not the person, so the calendar uses OAuth below.

Use an API key when the application acts as itself, the key lives in a secrets store rather than in code or on a laptop, and the API offers nothing better.

OAuth 2.0: trade a secret for a short-lived token

OAuth fixes the long-lived part with a middleman, the authorization server, or auth server for short. The client, our app, sends its long-lived secret only there, once in a while, and gets back an access token: valid for minutes to an hour, and limited to the scopes that were granted, like contacts.read. The API, the resource server, only ever sees the access token.

How the client gets the token is the grant type. Two cover almost every integration.

Client credentials: our app as itself

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorOne hourOur codeTheir API

The CRM integration has no human in it: our app reads accounts as itself. The CRM admin registers our app as a client, and the CRM’s admin console shows two values:

client_id:     northstar-support
client_secret: q8Zr2vLx7TfN4mKd9WbE

The client_id names the client and is not a secret: it shows up in logs, and in the calendar flow below, in the browser’s address bar. The client_secret is the password. Consoles often show it only once, so it goes straight into the secrets store.

Our appAuth serverCRM APIClient ID + secret1Access token, 1 h2Bearer access token3Public keys, once4JWKS5Checks the JWT6200: Alex’s account7Reuse the token for the hour

Two calls to get going: one to the auth server for a token, one to the API with it. After that, only the second, until the token expires.

The token request (1) is a form-encoded POST. The client authenticates with HTTP Basic: the two values joined by a colon, northstar-support:q8Zr2vLx7TfN4mKd9WbE, then base64-encoded:

POST /oauth/token HTTP/1.1
Host: auth.crm.example.com
Authorization: Basic bm9ydGhzdGFyLXN1cHBvcnQ6cThacjJ2THg3VGZONG1LZDlXYkU=
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=contacts.read%20cases.write

Base64 is there for transport, not secrecy: a header may only carry plain ASCII characters, and base64 turns any ID and secret into those, in a form the server decodes back. It is an encoding, not encryption: whoever sees that header has the secret. That is why it only ever travels over HTTPS, and only to the token endpoint.

The answer (2) holds the access token and how long it lasts, expires_in:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNybS0yMDI2LTEwIn0.eyJpc3Mi...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "contacts.read cases.write"
}

expires_in is seconds from now, not a time of day, so the two machines’ clocks don’t have to agree. It doesn’t decide when the token expires: the auth server does, and after that the API answers 401. It tells the client how long it can count on the token, so it can fetch the next one in time.

Every CRM call (3) then carries the access token:

GET /v2/contacts?account_number=NSB01234 HTTP/1.1
Host: api.crm.example.com
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNybS0yMDI2LTEwIn0.eyJpc3Mi...

The CRM API checks it without asking the auth server each time: it fetches the auth server’s public keys once (4, 5) and checks the JWT with them (6), as the next section shows. Then it answers (7):

HTTP/1.1 200 OK
Content-Type: application/json

{"account_number": "NSB01234", "name": "Alex Carter", "status": "locked", "security_flag": "suspicious_login"}

Two things are easy to get wrong:

  • Cache the token. A fresh one per call doubles the latency, and auth servers rate-limit the token endpoint. Keep it until shortly before expires_in runs out, and fetch a new one on a 401.
  • No refresh token here. Our app still has its client secret, so it just asks again.

The client_secret is long-lived too, so this can look like an API key with extra steps. What OAuth buys: the secret travels to one endpoint occasionally rather than on every call, what does travel expires, and it carries scopes.

The CRM’s token is a JWT

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorSelf-checkingOur codeTheir API

The CRM’s access token starts with eyJ, base64 for {": it is a JSON Web Token, three base64url parts separated by dots.

eyJhbGci….eyJpc3Mi….Kq3xT9…HeaderWhich key signed italgRS256kidcrm-2026-10PayloadReadable by anyoneissauth.crm.example.comsubnorthstar-supportaudapi.crm.example.comscopecontacts.read cases.writeexpin one hourSignatureProves who issued itinputeyJhbGci….eyJpc3Mi…signerauth server, private key crm-2026-10checkCRM: same input + public key crm-2026-10editchange one claim → check failsSigned, not encrypted

The CRM’s access token, decoded. The claims are what the API checks; the signature is why it can trust them.

The payload’s fields are claims: iss who issued it, sub who it is about (our app here, a user in a delegated flow), aud which API it is for, exp when it expires, scope what it allows. The API trusts them only once it has checked the signature, and it does that without asking anyone, in steps 4 to 6 above.

Steps 4 and 5: fetch the keys. The auth server signs with a private key and publishes the matching public keys as a JWKS (JSON Web Key Set) at a well-known URL. The API fetches them once and caches them:

GET /.well-known/jwks.json HTTP/1.1
Host: auth.crm.example.com
{
  "keys": [
    {
      "kid": "crm-2026-10",
      "kty": "RSA",
      "alg": "RS256",
      "use": "sig",
      "n": "u1SU1LfVLPHCozMxH2Mo4lgOEePzNm0tRgeLezV6ffAt0gunVTLw7onLRnrq0_IzW7yWR7QkrmBL7jTKEn5u...",
      "e": "AQAB"
    }
  ]
}

n and e are the RSA public key. Publishing it is safe: it can check signatures, not make them.

Step 6: check the token. The API picks the key the token’s header names as kid, verifies the signature with it, then checks the claims: issued by the right server, addressed to this API, not expired. Only then does it look at scope. No call to the auth server is needed, which is what JWTs buy.

If you run the API: step 6 in code

Verifying a JWT is more than checking the signature. With PyJWT:

import jwt  # PyJWT

jwks = jwt.PyJWKClient("https://auth.crm.example.com/.well-known/jwks.json")

def verify(token: str) -> dict:
    signing_key = jwks.get_signing_key_from_jwt(token)  # picks the key by "kid"
    return jwt.decode(
        token,
        signing_key.key,
        algorithms=["RS256"],                    # never trust the token's own "alg"
        audience="https://api.crm.example.com",  # minted for this API, not another one
        issuer="https://auth.crm.example.com",   # by the server we trust
        leeway=30,                               # tolerate small clock skew
        options={"require": ["exp", "iss", "aud"]},
    )
  • algorithms pins the algorithm. Early libraries trusted the header, so an attacker could set "alg": "none" and drop the signature, or switch RS256 to HS256 and sign with the public key as if it were a shared secret. The JWT best practices describe both.
  • audience stops a token minted for the ticketing API from being replayed against the CRM.
  • require rejects tokens that leave exp out and would otherwise never expire.

What that costs

Checking without asking anyone has consequences for everyone who handles the token:

  • Signed, not encrypted. Anyone holding the token can read the claims. No secrets go in them, and until exp the token is as good as a password to whoever holds it.
  • Can’t be taken back. A leaked JWT stays valid until exp. That is why access tokens are short-lived, and the long-lived trust sits in something the auth server checks on every use: the client secret here, the refresh token in the calendar flow below. An opaque token, a random string the API checks by asking the auth server (introspection), is revocable at once, at the cost of a lookup per request. The calendar’s tokens below are opaque.
  • Not meant for the caller. Our app doesn’t need to decode its token: it is addressed to the API, and the provider may change its format. Decoding it is still the fastest way to debug a 403: the scope or aud is usually wrong.

Where else JWTs show up

  • As the client’s credential. Some providers replace the client_secret with a JWT the client signs with its own private key (RFC 7523). Service accounts on large cloud and CRM platforms work like this: nothing reusable travels at all.
  • As an ID token. It tells an app who logged in, not what it may do at an API. Logging in shows the one the advisor gets when logging in to our app.

When a call fails: 401 or 403

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorRetry onceOur codeTheir API

The status code says which layer failed, as the bearer token spec defines them. Both fail the same CRM call, and the obvious first reaction, a new token and a retry, fixes one and not the other.

The two codes split along two words that sound alike: authentication (AuthN), proving who someone is, and authorization (AuthZ), deciding what they may do. Despite its name, 401 Unauthorized is about authentication.

401 Unauthorized: “I don’t know who you are.”

Our appAuth serverCRM APIBearer access token1Checks exp: passed2401: invalid_token3Client ID + secret4New access token5Retry once6200: Alex’s account7One retry fixes it

An expired token: one new token and one retry fix it.

Our app calls the CRM with the token it cached an hour ago (1). The CRM checks the JWT and finds exp in the past (2). A missing or malformed token, or one signed by someone the API doesn’t trust, ends the same way: it answers invalid_token (3):

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token", error_description="The access token expired"

Our app fetches a new token (4, 5), exactly as in client credentials.

It retries once (6), and gets Alex’s account (7). A second 401 right after a fresh token means the problem isn’t the token’s age, and another retry won’t help.

403 Forbidden: “I know who you are, and you may not do this.”

Our appAuth serverCRM APIUnlock the account1Checks scope: contacts.read2403: insufficient_scope3Client ID + secret4Same scopes again5Unlock the account6403 again7No retry fixes it

A missing scope: a new token carries the same scopes, so the retry fails the same way.

Our app tries to unlock Alex’s account (1). The token is valid, but its scope only says contacts.read (2), and unlocking needs contacts.write. The CRM answers insufficient_scope and names the scope it wanted (3):

HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", scope="contacts.write"

Handled like a 401, our app fetches a new token (4, 5). The auth server grants what the client is registered for, so the new token has the same scopes.

The retry (6) gets the same 403 (7). The fix is in the client’s configuration, usually on the provider’s side. Until then, retrying a 403 in a loop is a bug.

Authorization code: our app on someone’s behalf

Our appHolds the secretsAttaches one to each callTicketing systemAPI key on every callValid until rotatedCRMAuth server: secret → tokenAPI: checks the JWT itselfAdvisor’s calendarAdvisor consents onceRefresh token per advisorConsentOur codeTheir API

The second grant is for the calendar, which belongs to the advisor. Our app shouldn’t hold a key to every advisor’s calendar; it should act for the advisors who consented to it, on their calendars only. This delegation is what OAuth was built for, and the flow behind every “Allow this app to…” screen: the authorization code grant.

Four browser windows. 1: our app at support.northstar.example.com, Integrations, Calendar not connected, the advisor clicks Connect calendar. 4: redirected to auth.calendar.example.com/authorize with client_id and state in the URL, a Sign in page "to continue to Northstar Support" with email and password. 4: still at auth.calendar.example.com, a consent page: Northstar Support wants to access your calendar, create and edit events (calendar.events.write), Cancel or Allow. 5: redirected back to support.northstar.example.com/oauth/callback with a code and the state in the URL; the calendar now shows as connected. Four browser windows. 1: our app at support.northstar.example.com, Integrations, Calendar not connected, the advisor clicks Connect calendar. 4: redirected to auth.calendar.example.com/authorize with client_id and state in the URL, a Sign in page "to continue to Northstar Support" with email and password. 4: still at auth.calendar.example.com, a consent page: Northstar Support wants to access your calendar, create and edit events (calendar.events.write), Cancel or Allow. 5: redirected back to support.northstar.example.com/oauth/callback with a code and the state in the URL; the calendar now shows as connected.

What the advisor sees: our app sends them to the calendar provider, and the provider sends them back. Only the address bar shows whose page they are on.

AdvisorAuth serverOur appCalendarConnect calendar1State, verifier, challenge2Redirect: state, challenge3Log in, consent4Code, via browser5Checks state6Code + verifier7Checks verifier8Access + refresh9Bearer access token10An hour later, without the advisorRefresh token11New pair12Store the new refresh token

The advisor is in the loop once, for steps 1 to 5. Everything after happens between our app and the auth server.

It starts in our app: the advisor clicks “Connect calendar” (1). Before answering, our app makes up two random values for this one login (2) and keeps them in the advisor’s session:

  • state, an identifier for this login.
  • PKCE: a code_verifier, a secret, and its hash, the code_challenge. The verifier itself only travels in step 7, so only whoever started the flow can finish it. Current best practice asks for PKCE on every client.

Both tie the code that comes back to the login that asked for it. What they stop shows the two attacks.

Then it answers with a redirect (3), a 302 whose Location sends the advisor’s browser on to the calendar provider’s auth server, here with one parameter per line. It carries the state and the code_challenge, not the verifier:

https://auth.calendar.example.com/authorize
  ?response_type=code
  &client_id=northstar-support
  &redirect_uri=https://support.northstar.example.com/oauth/callback
  &scope=calendar.events.write
  &state=Xq7pV2mL9sKw
  &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
  &code_challenge_method=S256

The advisor logs in and consents (4) at the calendar provider, never at our app. We never see their password. With single sign-on, they may not even have to type it.

The auth server sends the browser back to our redirect_uri with a code and the same state (5):

https://support.northstar.example.com/oauth/callback?code=SplxlOBeZQQYbYS6WxSbIA&state=Xq7pV2mL9sKw

Our app checks the state against the one in the session (6) and drops it: it was only good for these few minutes.

The code is worth nothing on its own. Our app trades it (7) at the token endpoint, together with its own client_id and client_secret and the PKCE code_verifier:

POST /oauth/token HTTP/1.1
Host: auth.calendar.example.com
Authorization: Basic <client_id:client_secret, base64-encoded>
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA&redirect_uri=https%3A%2F%2Fsupport.northstar.example.com%2Foauth%2Fcallback&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk

The auth server hashes the code_verifier and compares it with the code_challenge from step 3 (8). If they match, it answers (9), with one field more than in client credentials, the refresh token:

{
  "access_token": "cal_at_7Hq2Lm9xPv4T...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "cal_rt_9KdLw3ZnQ8bY...",
  "scope": "calendar.events.write"
}

Unlike the CRM’s JWT, these tokens are opaque: random strings the calendar can only check by looking them up. The access token goes on the calendar call (10), as a bearer token like any other:

POST /v1/me/events HTTP/1.1
Host: api.calendar.example.com
Authorization: Bearer cal_at_7Hq2Lm9xPv4T...
Content-Type: application/json

{"title": "Call: Alex Carter, locked account", "start": "2026-10-27T10:00:00+01:00", "duration_minutes": 15}

The refresh token is the long-lived secret here. It goes in the secrets store, one per advisor, and an hour later gets a new access token without the advisor (11):

POST /oauth/token HTTP/1.1
Host: auth.calendar.example.com
Authorization: Basic <client_id:client_secret, base64-encoded>
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=cal_rt_9KdLw3ZnQ8bY...

Many providers rotate it: the answer (12) holds a new refresh token as well and invalidates the old one.

{
  "access_token": "cal_at_Rt5Vn1qXc8Jw...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "cal_rt_Bw6Hs2Mk4Pz...",
  "scope": "calendar.events.write"
}

An integration that forgets to store the new one works for exactly one hour.

Two more grants are in the original spec, and current best practice (RFC 9700) says not to use them: the implicit grant, which returned the token in the URL, and the password grant, where the client collects the user’s password itself.

What state and PKCE stop

The code travels through the browser, which our app doesn’t control. Each of the two values stops one way of abusing that: an attacker’s code in the advisor’s session, and the advisor’s code in the attacker’s session.

AttackerAdvisorAuth serverOur appConsents, own calendar1Code, kept2Link with that code3Callback, attacker’s code4Checks state: no match5Login rejected6The advisor’s session stays clean

The attacker's code in the advisor's session. The state check in step 5 rejects it.

The attacker logs in at the calendar provider with their own account and consents to access to their own calendar (1). They keep the code it sends back (2) rather than let their browser redeem it.

They get the advisor, who is logged in to our app, to open a link to our callback with that code (3), in an email or on a web page. The advisor’s browser follows it (4).

Without a state check, our app would trade the code and store tokens for the attacker’s calendar under the advisor. Every call our app books, “Alex Carter, locked account” included, would land in the attacker’s calendar.

With it, our app finds no matching state in the advisor’s session (5): the advisor never started this login. It rejects the callback (6) before trading anything.

PKCE stops this one too: the attacker’s code was issued against the attacker’s challenge, and the advisor’s session holds no verifier for it. That is why current best practice lets a client rely on PKCE alone when the auth server supports it. The mirror image is the attack only PKCE stops.

AdvisorAttackerOur appAuth serverCode leaks1Connect calendar2Own state, challenge3Stolen code, own state4Checks state: match5Code + verifier6Checks verifier: no match7400: invalid_grant8No tokens for the attacker

The advisor's code in the attacker's session. The state check passes; the verifier check in step 7 rejects it.

The advisor connects their calendar as usual, but the code leaks to the attacker (1), from a log or a malicious browser extension, before our app redeems it. Codes are single-use, so the attacker has to be quicker.

The attacker, who has an account in our app, clicks “Connect calendar” themselves (2). Our app makes a state and a verifier for the attacker’s session and answers with the redirect (3).

The attacker stops there and calls our callback directly, with the stolen code and their own state (4). The state matches the attacker’s session (5): state only proves the callback belongs to a login this browser started, not whose code it carries.

Our app trades the code with the verifier it holds for the attacker’s session (6). Our client secret is no obstacle, since it is our own app making the call. The auth server hashes that verifier and compares it with the challenge the code was issued for, the advisor’s (7). They don’t match, and it answers with an error instead of tokens (8):

HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error": "invalid_grant", "error_description": "PKCE verification failed"}

Without PKCE, the auth server would hand our app tokens for the advisor’s calendar, filed under the attacker’s session: whatever our app does with a connected calendar, it would now do on the advisor’s calendar for the attacker.

Logging in: OpenID Connect and SSO

The authorization code flow began with the advisor clicking “Connect calendar” in our app, so our app already knew who they were. OAuth can’t have told it. OAuth is authorization: its access token says what an app may do at an API, it is addressed to that API, and the app isn’t meant to read it. Knowing who someone is, authentication, takes one more layer.

AdvisorOur appKeycloakAuth serverOpens the app1Redirect to IdP2Password, 2nd factor3Starts IdP session4Code, via browser5Code + verifier6ID + access token7Checks ID token8Later: Connect calendarSent there to log in9Login, via browser10Session found11Who it is12Consent screen only13One login, every app

The advisor types a password once, at the IdP. Every app after that, the calendar's auth server included, gets their identity from it.

In the morning the advisor opens our app (1). It has no login form of its own: it redirects them (2) to the bank’s identity provider (IdP), the one system that holds the employees’ accounts, passwords and second factors, and that every internal app sends its users to for login. Say Northstar runs Keycloak, an open-source IdP a company hosts itself; Microsoft Entra ID and Okta are common hosted ones. Under the hood an IdP is an OAuth auth server like the CRM’s or the calendar’s, with people as its main business. It hands out tokens to machines too: an in-house CRM could sit behind Keycloak, and client credentials would work against it unchanged.

The advisor logs in there (3), not at our app, and Keycloak remembers that with a session of its own (4).

The rest is the authorization code flow from above, state and PKCE included, with one more scope, openid. Keycloak sends a code back through the browser (5), and our app trades it (6).

The openid scope switches on OpenID Connect (OIDC), a thin layer on OAuth that adds authentication. Next to the access token, Keycloak returns (7) an ID token: a JWT addressed to our app (its aud is our client_id), with claims like sub, a stable ID for the advisor, and email. “Sign in with Google” works the same way, with Google as the IdP.

Our app checks the ID token like any JWT (8) and starts its own session for the advisor. The rule of thumb: the access token is for the API, the ID token for the app; sending an ID token to an API is a classic mix-up.

Later the advisor clicks “Connect calendar”, and the calendar’s auth server wants them to log in (9). If the bank set it up to trust its IdP, it shows no password field and sends them on to Keycloak (10). One auth server handing its login to another like this is federation.

Keycloak finds the session from the morning (11) and tells the calendar’s auth server who the advisor is (12), without asking for a password. Only the consent screen is left (13).

That is single sign-on (SSO): not a protocol, but what you get when many apps hand their login to one IdP. Older enterprise apps often do the same over SAML, an XML-based predecessor of OIDC; Keycloak speaks both.

Three systems, three credentials

  • Ticketing: an API key, sent with every call. Our app acts as itself, and the key lives until someone rotates it.
  • CRM: client credentials. Our app trades its secret for an hour-long token, a JWT the API checks on its own.
  • Calendar: authorization code. The advisor consents once, and our app keeps a refresh token per advisor to get short-lived, opaque tokens for their calendar.

So the question for a new API is not which of the three to use. It is whose data the call touches, which decides the grant, and which secret our app has to keep, which decides where it is stored.

This post looks at it from the caller’s side. When the Agent Calls You turns it around: an MCP server whose callers are AI apps it has never met.

AI Chat

Messages you send are processed by the Google Gemini API to generate responses. Do not share sensitive personal data. See the privacy policy for details.