Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

When a scope is refused or quietly dropped

A scope request passes four separate checks, and a token request that worked for months can start failing when any one of them changes. This lesson follows the printing company's nightly job after a scope clean-up, finds the list that changed, and restores one assignment without undoing the part of the clean-up that was right.

The nightly print job stops

All names, domains and identifiers in these examples are fictional. You work on the team that runs the photo service's authorization server at auth.photos.example. At 07:10 on a Wednesday, a message arrives from Joel, an integration engineer at the printing company: "Our nightly order job failed for the first time in months. It placed none of last night's 214 photo books. The token endpoint says invalid_scope, and we haven't changed anything. Request ID attached."

The job runs at 02:00 with no user present. It collects the photo books customers approved during the day and places them with the photo service's print-order API at api.photos.example. It is a confidential client called printer-sync, and it gets its access token with the client credentials grant: it authenticates as itself at the token endpoint and asks for the scopes it needs. Joel has sent the request the job made, with its credential removed, and the answer it got:

POST /token HTTP/1.1
Host: auth.photos.example
Authorization: Basic <redacted>
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=prints.read+prints.create&resource=https%3A%2F%2Fapi.photos.example%2F

HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
X-Request-ID: 0b7e4d19-52a8-4f0c-9d61-3c2a7e5f1b08

{"error": "invalid_scope",
 "error_description": "One or more requested scopes are not permitted for this client."}

That pins the failing stage. No token was issued, so nothing ever reached the print-order API. Client authentication passed, too, because a server that cannot identify the client answers invalid_client instead, as Errors and denied access listed. RFC 6749 uses invalid_scope when a requested scope is invalid, unknown, malformed or beyond what the client may have. That covers several different faults, and this description does not say which scope failed or why.

Joel is right that the job did not change. The same request got a token at 02:00 the night before. If the request is unchanged and the answer changed, something on your side of the comparison moved, and the client's change history has one entry since the last good run:

time     2026-10-13T16:48:22Z
actor    marisol.sandoval
action   oauth.client.scopes.update
client   printer-sync
before   prints.read prints.create photos.delete
after    prints.read
note     "Removing unused scopes from partner clients"

Your teammate Marisol spent yesterday afternoon tidying up partner clients. That record is a strong lead, but it is not yet a diagnosis. A change that lands near a failure explains it only when what the change touched reproduces the failure, as Finding the failing stage put it.

Compare four lists

A scope request succeeds only when every scope in it passes four separate checks, and each check reads from its own list. Line them up for this request one at a time, and the fault usually stands out.

The scopes requested. Read them from the request itself, not from the job's documentation or someone's memory of its configuration. The scope parameter is a list of space-separated values, and each value is compared as an exact string, capital letters included, so prints.Create or print.create is a different scope. In a form body the space is usually encoded as +. Here the job asked for prints.read and prints.create.

The scopes the server defines. A scope nobody defined fails here, such as an albums.export that a developer guessed at while adding a feature. If the server publishes metadata, its scopes_supported list is a convenient place to look, but a server may leave scopes off that list. A missing entry does not prove a scope is undefined, and a listed one is not permission to use it. Both of the job's scopes are defined.

The scopes this client may be granted. Most servers keep a per-client list of assigned or allowed scopes. With the client credentials grant there is no user to consent, so this list is the whole decision. Since yesterday afternoon, printer-sync may be granted only prints.read.

The scopes that belong to the API named in the request. The resource parameter, defined in RFC 8707, tells the server which API the token is for, as Scopes and audiences explained. On servers that organize scopes by API, a scope that belongs to a different API does not fit the request, and depending on the server that is refused as invalid_scope or invalid_target. RFC 8707 defines invalid_target for a resource the server will not issue a token for, such as one that is unknown or malformed. Both scopes belong to the print-order API at https://api.photos.example/, which the request names correctly.

Laid out side by side, the four lists make the comparison at a glance. Each row is one scope and each column one check, so a fault shows as the one "No" in a row the job requested:

The four scope lists for the printer-sync token request
ScopeRequestedDefinedAssigned to printer-syncBelongs to the print-order API
prints.readYesYesYesYes
prints.createYesYesNo, removed 2026-10-13 16:48 UTCYes
photos.deleteNoYesNo, removed 2026-10-13 16:48 UTCNo, it belongs to the photo API

Only one requested value fails a list: prints.create is requested, defined and appropriate for the API, but this client is no longer allowed it. Now test that against the server instead of trusting the comparison. Ask for prints.read alone with the same client, and a token comes back with "scope": "prints.read". Ask for prints.create alone, and you get the same invalid_scope. The server's audit record for the original refusal agrees, once you look it up by Joel's request ID:

time        2026-10-14T02:00:03.117Z
operation   oauth.token
grant       client_credentials
outcome     rejected
reason      scope_not_assigned
client      printer-sync
detail      requested=prints.read prints.create  not_assigned=prints.create
request_id  0b7e4d19-52a8-4f0c-9d61-3c2a7e5f1b08

The protocol response stayed vague on purpose, because a partner does not need your internal policy to fix its request. Your own record is specific, and it names the exact scope that Marisol's change removed. The other scope she removed, photos.delete, was assigned years ago for a clean-up feature the printing company has since retired. The job never uses it, and removing it was the right call. Her tidy-up was half right, and the half that was wrong stopped a production job.

The same fault can surface at the API

Your server refuses the whole request when any scope in it is not allowed, which is why Joel's job failed at the token endpoint with a clear error. Plenty of servers behave differently. RFC 6749 section 3.3 lets the authorization server issue a token with fewer scopes than the client asked for, based on its policy or on what the user approved. When it does, it must include a scope parameter in the response saying what was actually granted. Against a server like that, the same tidy-up produces a successful token response:

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store

{"access_token": "<redacted>",
 "token_type": "Bearer",
 "expires_in": 3600,
 "scope": "prints.read"}

Nothing in that response looks like an error, and a job that ignores the scope field carries on. Its first visible failure comes a moment later, when it tries to place an order and the print-order API refuses the token with the insufficient_scope challenge Using access tokens described:

POST /print-orders HTTP/1.1
Host: api.photos.example
Authorization: Bearer <redacted>
Content-Type: application/json

HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
    error_description="Placing an order requires a scope this token does not carry",
    scope="prints.create"

Now the job's log says "403 from the print-order API", and the natural first suspect is the API, which did nothing wrong. It validated the token, saw that it carried only prints.read and refused an operation that needs prints.create. The optional scope attribute in the challenge even names what was missing. In both cases the cause is the same: prints.create is no longer assigned to printer-sync. Only the stage where it shows differs.

Refuses the whole request

Requested
prints.read prints.create
Token response
400 invalid_scope
Scope issued
None
Print order
Never sent
Shows at
Token endpoint

Clear error, no token

Trims the request

Requested
prints.read prints.create
Token response
200 OK
Scope issued
prints.read
Print order
403 insufficient_scope
Shows at
Print-order API

Looks like an API fault

In both cases the cause is the same: prints.create is no longer assigned to printer-sync.

The same removed assignment at two kinds of server. One refuses the token request; the other issues a shorter token, and the failure shows at the print-order API.

So whenever a scope problem is possible, compare the scope in the token response with the scope you requested. If the response omits scope, the server is saying it granted exactly what you asked for. If it includes a shorter list, the server trimmed your request, and any 403 that follows is explained before you open the API's logs. A well-built client makes that comparison itself and fails loudly the moment a scope it depends on is missing, rather than leaving the discovery to the first refused API call.

Timing can mislead in the same way. A change to a client's assignments affects tokens issued after it. A token issued earlier usually keeps the scopes it was issued with until it expires, so a job that caches tokens may run for another hour after the change and then fail, far enough from the change that nobody connects the two.

Restore one assignment and prove the boundary

The repair is to assign prints.create to printer-sync again, and nothing else. A few broader fixes are tempting, and each one is wrong. Assigning every print and photo scope "so this never happens again" gives a partner's unattended job authority it has never needed. Restoring Marisol's whole "before" list puts photos.delete back, which undoes the part of her change that was correct. Switching the server to drop unassigned scopes quietly would turn this clear error into the harder 403 you just read about. And asking Joel to stop requesting prints.create would make the token request succeed and leave the job unable to place a single order.

After saving the assignment, verify in both directions with fresh tokens. First the work that should succeed: a new token request returns "scope": "prints.read prints.create", and Joel reruns the job, which places all 214 orders with 201 Created responses. Then a request that must still be refused, using a scope this client was never meant to have:

POST /token HTTP/1.1
Host: auth.photos.example
Authorization: Basic <redacted>
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=prints.create+photos.delete&resource=https%3A%2F%2Fapi.photos.example%2F

HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
X-Request-ID: 6a2c90f3-1e47-4b8d-a5d2-7f09c3e18b64

{"error": "invalid_scope",
 "error_description": "One or more requested scopes are not permitted for this client."}

The error code is the same as last night's, and this time the refusal is correct. Last night a scope the job needs had been taken away. This morning a scope it has no business holding is refused, and only the lists tell those two apart.

One more thing belongs in your reply to Marisol. Before removing a scope from a client, look up whether the client has requested it recently. The server's token records answer that in a minute, and they would have shown prints.create in every nightly request.

Worked example: the handoff note

The note that went into the incident record names the stage, the record that proved the cause, the repair and both directions of the check, and it says which part of the change stayed:

Symptom:       printer-sync nightly run at 02:00 UTC placed 0 of 214 orders.
Failing stage: Token request, 400 invalid_scope (request 0b7e4d19-52a8-4f0c-9d61-3c2a7e5f1b08).
               Client authentication passed. No token issued, no API calls made.
Cause:         Scope clean-up on 2026-10-13 at 16:48 UTC removed prints.create from printer-sync.
               audit reason scope_not_assigned, not_assigned=prints.create. Reproduced:
               prints.read alone is issued, prints.create alone is refused.
Repair:        Reassigned prints.create only. photos.delete stays removed (unused, retired feature).
Verification:  New token scope "prints.read prints.create". Rerun placed 214 orders (201).
               prints.create with photos.delete: still 400 invalid_scope
               (request 6a2c90f3-1e47-4b8d-a5d2-7f09c3e18b64).
Not changed:   Job code, client credential, server scope policy.
Follow-up:     Check recent token requests before removing scopes from partner clients.

The follow-up line turns one incident into a change to how clean-ups are done, which is the part most likely to stop the next one.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A nightly job requests orders.read orders.write. The token response is 200 and includes "scope": "orders.read". The job's first write then gets 403 with error="insufficient_scope". Where should you look first? 1 of 2

Choose one answer.

After a scope cleanup, a client's token request fails with invalid_scope. The audit record says not_assigned=prints.create. The cleanup also removed photos.delete, which the client never uses. Which repair is right? 2 of 2

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity