# How to choose a hosted or self-built authorization server

> Score Auth0, Cognito, Keycloak, Ory Hydra, and node-oidc-provider from quoted vendor pages, then run the OAuth flows against the front runner.

Source: https://voxgig.com/howto/choose-a-hosted-or-self-built-authorization-server

- Audience: platform-team
- Level: beginner
- Verified: 2026-11-30
- Published: 2026-11-30

## Short answer

Score each candidate on machine-to-machine token pricing, user pricing, RFC 7591 registration, who runs it, data residency, custom claims, and exit cost. Put a vendor quote behind every score, and one rule for all. Compare the totals under equal and under your own weights. Then spike the leader: run client credentials, authorization code with PKCE, and a refresh against it, and change a scope to see when tokens carry it.

---
## You will need

Node 22 or later for the sample. A list of the clients your API must serve, which flows each one
uses, and an estimate of machine token requests per month. The prices below are quoted from each
vendor's pricing page on the day of the last verification, so read the pages again before you
sign anything.

## Approaches compared

| Approach | When it fits | What it costs you | When to pick something else |
| --- | --- | --- | --- |
| [Amazon Cognito](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-define-resource-servers.html) | You run on AWS and stay inside the Lite or Essentials free tier of 10,000 monthly active users | Every client credentials token request is billed, with no free tier for machine-to-machine use | Machine clients outnumber people, or clients must register themselves |
| [Auth0](https://auth0.com/docs/get-started/applications/dynamic-client-registration) | Up to 25,000 monthly active users free, and third-party clients that register themselves | Machine-to-machine authentication listed at 1,000 on Free, with an add-on only on Professional and Enterprise | Agent traffic will dwarf the machine-to-machine figure on your plan |
| [Keycloak](https://www.keycloak.org/securing-apps/client-registration) | A team that can run a Java service, its database, and its upgrades | You run, patch, and back up the server and its database, with nobody else on call | Nobody will hold the pager for the identity tier |
| [node-oidc-provider](https://github.com/panva/node-oidc-provider/blob/v9.15.1/docs/README.md) | You need your exact scheme, in Node, and accept writing login and consent | Login pages, storage, key rotation, and every security patch are your code from then on | You want an administration console and user accounts included |
| [Ory Hydra](https://www.ory.com/docs/hydra/guides/oauth2-clients) | You already have user accounts and want only the OAuth server, self-hosted or on Ory Network | You supply the login and consent app, and Ory Network prices each machine token | You want user accounts and login pages in the same product |

The two hosted services remove the on-call rota and the security patching, and meter the traffic
in exchange. [Cognito's pricing page](https://aws.amazon.com/cognito/pricing/) says there is no
free tier for token requests in the machine-to-machine case.[^1] The [Auth0 pricing page](https://auth0.com/pricing)
lists 1,000 for machine-to-machine authentication on its Free plan. The three open source servers
charge nothing per token, so the cost
moves to your team. Keycloak brings user management, and node-oidc-provider is a library you
assemble. Ory [describes its OAuth 2.0 service](https://www.ory.com/docs/network/hydra) as a headless
API that doesn't force you to use a specific user management system.

## Put a quote behind every score

The sheet is a JSON file. Each score is 0, 1, or 2 under one rule per criterion, and carries the
sentence it rests on and the page that says it. A 0 that rests on an absence names the pages
searched and a control page where the same term is found.

```json title="candidates.json"
      "name": "Auth0",
      "scores": {
        "m2m": { "score": 1, "url": "https://auth0.com/pricing", "quote": "Machine-to-Machine Authentication 1,000 1,000 5,000 5,000 M2M Add-on No No Yes Yes" },
        "users": { "score": 1, "url": "https://auth0.com/pricing", "quote": "Up to 25,000 monthly active users" },
        "dcr": { "score": 2, "url": "https://auth0.com/docs/get-started/applications/dynamic-client-registration", "quote": "Dynamic Client Registration (DCR) is based on the OpenID Connect Dynamic Client Registration specification" },
        "operations": { "score": 2, "url": "https://auth0.com/pricing", "quote": "over our standard public cloud offering" },
        "exit": { "score": 1, "url": "https://auth0.com/pricing", "quote": "With it, you can export all data to any format" },
        "residency": null,
        "claims": null
      }
```

`record.sh` downloads every cited page and checks each quote, each search, and each control
against it. Its 35 checks passed. Data residency and custom claims are `null`: those depend on
the region and the plan you would buy, so you fill them in. The scorer leaves a criterion out of
the totals until every candidate has a score for it.

```bash
node score.mjs
```

```text output
                    M2M tokens users      RFC 7591   on-call    exit       residency  claims
Amazon Cognito      0          1          0          2          0          -          -
Auth0               1          1          2          2          1          -          -
Keycloak            2          2          2          0          2          -          -
Ory Hydra           2          2          2          0          2          -          -
node-oidc-provider  2          2          2          0          2          -          -

scored on: M2M tokens, users, RFC 7591, on-call, exit
still to score: residency, claims
weights: M2M tokens 3, users 1, RFC 7591 2, on-call 2, exit 1

equal weights            given weights
Keycloak 8               Keycloak 14
Ory Hydra 8              Ory Hydra 14
node-oidc-provider 8     node-oidc-provider 14
Auth0 7                  Auth0 13
Amazon Cognito 3         Amazon Cognito 5
```

The three open source servers tie because the sheet counts what they cost you on one row,
on-call, and what they save on four. Raise the on-call weight in `weights.json` from 2 to 3 and
Auth0 leads.
Cognito scores 0 on registration because the three Cognito pages searched never mention it, not
because a page says it is absent. Its 0 on exit rests the same way on two pages without the word
"export."

## Spike the front runner on your own machine

The spike stands up node-oidc-provider on 127.0.0.1 with the features the plan needs. Login and
consent are automatic for one test user, which stands in for the pages a deployment draws.

```js title="as.mjs"
    features: {
      devInteractions: { enabled: false },
      clientCredentials: { enabled: true },
      registration: { enabled: true, initialAccessToken },
      registrationManagement: { enabled: true, rotateRegistrationAccessToken: false },
```

The script registers a client under
[RFC 7591](https://www.rfc-editor.org/rfc/rfc7591.html), runs client credentials, runs
authorization code with [PKCE](https://www.rfc-editor.org/rfc/rfc7636.html) and a refresh, and
then widens the client's scope through the
[RFC 7592](https://www.rfc-editor.org/rfc/rfc7592.html) update endpoint.[^2]

```bash
node spike.mjs
```

```text output
dynamic registration (RFC 7591)              201, client_secret issued: true
client credentials                           200, scope "orders:read", aud the API
client credentials, scope not registered     400 invalid_scope
authorization code with PKCE                 200, scope "orders:read", refresh token: true
refresh                                      200, scope "orders:read", rotated: true
scope change (RFC 7592 update)               200
next client credentials token                200, scope "orders:read orders:write"
token issued before the change               scope "orders:read", lives 600 s
```

A scope change reaches the next token at once. A token issued before it keeps the earlier scope until
it expires, after the 600 seconds this server is configured for.

`record.sh` ran the same plan against Ory Hydra 2.3.0, downloaded from its release page and
checked against the release's SHA-256. The functions in `flows.mjs` take Hydra's endpoint paths,
and a short stand-in accepts its login and consent requests:

```bash
cat records/hydra-spike.txt
```

```text output
dynamic registration (RFC 7591)              201, client_secret issued: true
client credentials                           200, scope "orders:read"
client credentials, scope not registered     400 invalid_scope
authorization code with PKCE                 200, scope "openid offline_access orders:read", refresh token: true
refresh                                      200, scope "openid offline_access orders:read", rotated: true
scope change (RFC 7592 update)               200
next client credentials token                200, scope "orders:read orders:write"
token issued before the change               scope "orders:read", lives 10 min
```

Hydra gave the same answers. On a hosted candidate, run the same flows against its free tier and
record how long a change made in its dashboard takes to show up in a fresh token.

## Check it worked

The suite pins the sheet's rules and every flow in the spike, including a public client refused for
leaving out PKCE, a wrong code verifier refused, and a reused refresh token refused.

```bash
node --test spike.test.mjs
```

```text output
1..14
# tests 14
# suites 0
# pass 14
# fail 0
# cancelled 0
# skipped 0
# todo 0
```

## When it goes wrong

The bill jumps the month an agent integration ships. Its client requests a client credentials
token per call, and the plan prices tokens. The arithmetic uses the price
[Ory Network's pricing page](https://www.ory.com/pricing) gives for its Production plan, read from
the quote `record.sh` checked:

```bash
node meter.mjs
```

```text output
4 agent instances, a 30-day month, Ory Network Production at $0.007 a token
token policy                              tokens        cost
a token per call, one call a second     10368000   $72576.00
a token every 5 minutes                    34560     $241.92
one token per 1 hour lifetime               2880      $20.16
usage at that price, before the $21.00 monthly credit the plan includes
```

Cache the token until it nears expiry, as `cachedToken` in `flows.mjs` does. The suite shows ten
concurrent calls sharing one token request, against ten requests without the cache.

The scores stop matching the pages. Vendors change plans without notice, so run `record.sh` again
before a decision meeting; a failed quote check exits non-zero.

## When not to do this

Do not score on the free tier alone. A free tier sized for people says nothing about the
tokens your machine clients will request.

Do not self-build because the sheet says it is free. node-oidc-provider gives you the exact scheme
you designed and a codebase you must patch for as long as it runs. Choose Auth0 or Cognito when
nobody on the team can own that.

Do not skip the spike because the documentation lists the feature. Run the three flows and the
scope change against a free tier or a local copy. What a scope change does to tokens already
issued depends on each server's token lifetime and format.

## Related how-tos

- [Pick an OAuth library, a hand-rolled flow, or a vendor SDK](/howto/pick-an-oauth-client-library-or-hosted-sdk)

- [Get a client credentials token for calls between services](/howto/client-credentials-for-service-to-service-calls)

- [Run authorization code with PKCE in a single-page app](/howto/pkce-in-a-single-page-app)

- [Enforce scopes at the resource server, not in the client](/howto/enforce-scopes-at-the-resource-server)

- [Verify HMAC-signed requests and reject replays](/howto/verify-hmac-signed-requests-and-reject-replays)

## Last verified

Verified 2026-11-30 against Node 22.23.5, oidc-provider 9.15.1, `jose` 6.2.18, and Ory Hydra
2.3.0, which `record.sh` ran. Every output block is what the command preceding it printed. Auth0,
Amazon Cognito, Ory Network, and Keycloak were not run. Their scores and prices come from the
pages listed in `candidates.json`, fetched and checked by `record.sh` on the same day.

[^1]: The same [pricing page](https://aws.amazon.com/cognito/pricing/) says the user free tier
does not automatically expire at the end of the 12-month AWS Free Tier term, and is available
indefinitely. On the Lite and Essentials tiers, ten thousand people a month who sign in directly
or through a social provider cost nothing for as long as the account exists. A machine pays from
its first token request.

[^2]: Both documents date from July 2015. [RFC 7591](https://www.rfc-editor.org/rfc/rfc7591.html)
is on the Standards Track and covers creating a registration.
[RFC 7592](https://www.rfc-editor.org/rfc/rfc7592.html), which covers reading, updating, and
deleting one, is filed as Experimental, so the half of the spike that changes a scope rests on
the experimental half of the pair.