Skip to content
All articles
Protocols28 February 2025·3 min read

How to add granular permissions to your API using OAuth scopes

Protocol work looks tedious from the outside and turns out to be where the interesting failures live.

Paycux engineering

Protocol work looks tedious from the outside and turns out to be where the interesting failures live. The specification is short; the space of things implementers actually ship is not.

This piece walks through how we think about it at Paycux, what we have changed our minds about, and where the sharp edges are.

What are OAuth scopes?

Consider what are oauth scopes?. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Example of OAuth scopes

That brings us to example of oauth scopes. Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

  • Validate signature, issuer, audience and expiry as four separate checks
  • Normalize provider attributes into one internal shape
  • Fail loudly when a peer stops meeting a documented assumption
  • Keep a fixture per provider so regressions surface in CI

Scopes are not the same as access control

Scopes are not the same as access control deserves its own treatment. Version the assumption, not just the code. Write down what you expect from the peer, and make the failure loud when it stops being true, because the alternative is a connection that half works for six weeks.

Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

How to add granular permissions to your API

Consider how to add granular permissions to your api. Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Version the assumption, not just the code.

Define scopes

Consider define scopes. Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Request scopes during authorization

That brings us to request scopes during authorization. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Treat anything the other side sends as untrusted input until it has been through validation you wrote. Signature checks, issuer checks, audience checks and expiry checks are four separate decisions, and skipping any one of them is a real vulnerability rather than a theoretical one.

Check scopes in your API

That brings us to check scopes in your api. Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Normalization is the whole job. Two providers can be perfectly compliant and still disagree about what a group membership is, whether a logout is meaningful, and which attribute carries the email address.

Where this leaves us

None of this is exotic. It is the ordinary discipline of deciding what you own, writing down what you assume, and making the failures loud enough to notice.

If you are working through the same problem and want to compare notes, the docs cover the mechanics and the console shows the behaviour on your own data.

Everything here, already built

Sign-in, enterprise SSO, directory provisioning, roles and an audit trail behind one API. Start with the quickstart and have a working sign-in this afternoon.

Start selling to enterprise customers

Create an account, point sign-in at Paycux, and get back to the part of the product that is actually yours.