Core (Authz)
The Authentication API is a full-featured OAuth 2.0 server implementation that specializes in secure machine-to-machine (M2M) authentication using the client credentials back channel flow. This flow is optimized for server-side applications that need to securely communicate with APIs without user interaction.
As a complete OAuth 2.0 authorization server, the API provides:
/v1/oauth2/token — Issues access tokens to clients using the client credentials grant type, supporting secure back channel communication/v1/oauth2/introspect — Validates tokens and returns metadata about their scope and validity/v1/basic/introspect — Checks the HTTP Basic credentials of older clients with the legacy basic auth method. New clients use OAuth 2.0 and check tokens with /v1/oauth2/introspectTo use the APIs you need a client. To get your first one, send an email to hello@neobits.no with details about your integration needs. A client has three values:
id: a UUID that identifies the client. Its tokens carry it as sub and client_id.username: a generated name such as violent-boa-8290.password: the client secret. It is returned only when the client is created, so store it then.Core is served from your tenant's host: https://{tenant}.core.server.test.neobits.ai for test and https://{tenant}.core.server.prod.neobits.ai for production.
For OAuth 2.0 authentication, your server application should:
/v1/oauth2/token endpoint. Authenticate with HTTP Basic, sending your client's username and password as Authorization: Basic base64(username:password). Use the password exactly as you received it.expires_in field of the token response gives the lifetime in seconds.max_session_duration. It defaults to 28800 seconds (8 hours), which is also the maximum.session_duration with the token request to get a shorter-lived token. The issued lifetime is the lower of the two values.401.resource parameter becomes the token's audience (for example https://your-tenant.fuse.server.prod.neobits.ai). A token is only accepted by the API it was issued for. You can request your tenant's host of each API your client has a scope for.Scopes are assigned to your client when it is created. A token carries only the scopes you request in the scope parameter (or the scopes of the requested role), so request every scope the endpoints you call need. Requesting a scope that is not assigned to your client fails with invalid_scope, and calling an endpoint without its scope returns 403.
Core client management scopes:
clients:readclient:readclient:write, plus subscription:read to set its subscription_idclient:deleteCore subscription and product scopes:
subscriptions:readsubscription:readproducts:readSee the Fuse and Logic introductions for their scopes.
A client holds either a scope or a role. A role grants a bundle of scopes. From most to least privileged, the roles are owner, admin, member, viewer and guest.
role carries every scope of the role. A token requested with scope carries only the scopes you name, which must be among the role's.role, for its own role or a less privileged one.Of the scopes in these docs, each role grants:
clients:read, client:read, client:write, client:delete, subscription:read, subscriptions:read, products:read, every Fuse scope and every Logic scope.clients:read, client:read, client:write, products:read; Fuse's inquiry:write, inquiry:read, person:read and terms:read; Logic's environments:read, environment:read, deployments:read and deployment:read.clients:read, client:read, products:read; Fuse's inquiry:read, person:read and terms:read; Logic's environments:read, environment:read, deployments:read and deployment:read.To see what your own client holds:
scope=client:read./v1/oauth2/introspect. The response's sub is your client's id.GET /v1/clients/{id} with the token. The response has your client's scope or its role. A client with a role holds the role's scopes, listed under Roles.curl --request POST 'https://your-tenant.core.server.test.neobits.ai/v1/oauth2/token' \
--user "$CLIENT_USERNAME:$CLIENT_PASSWORD" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'resource=https://your-tenant.core.server.test.neobits.ai' \
--data-urlencode 'scope=client:read'
curl --request POST 'https://your-tenant.core.server.test.neobits.ai/v1/oauth2/introspect' \
--user "$CLIENT_USERNAME:$CLIENT_PASSWORD" \
--data-urlencode "token=$ACCESS_TOKEN"
curl "https://your-tenant.core.server.test.neobits.ai/v1/clients/$CLIENT_ID" \
--header "Authorization: Bearer $ACCESS_TOKEN"
If the token request fails with invalid_scope, your client doesn't hold client:read. Ask whoever created the client, or Neobits, which scopes it holds.
Fuse serves your client under its subscription, and returns only the data that subscription's products include. If Get a person leaves out fields you expect, such as income, check your products. To see them:
subscription_id with GET /v1/clients/{id}, as in Your Client's Scopes and Role. If it is null, Fuse answers your client with 403.scope=subscription:read products:read.GET /v1/subscriptions/{subscription_id} for the subscription's plan and dates.GET /v1/products for the products of your tenant's active subscriptions, such as Fuse inntektsinformasjon: A-meldingen. With one subscription, these are its products.curl --request POST 'https://your-tenant.core.server.test.neobits.ai/v1/oauth2/token' \
--user "$CLIENT_USERNAME:$CLIENT_PASSWORD" \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'resource=https://your-tenant.core.server.test.neobits.ai' \
--data-urlencode 'scope=subscription:read products:read'
curl "https://your-tenant.core.server.test.neobits.ai/v1/subscriptions/$SUBSCRIPTION_ID" \
--header "Authorization: Bearer $ACCESS_TOKEN"
curl 'https://your-tenant.core.server.test.neobits.ai/v1/products' \
--header "Authorization: Bearer $ACCESS_TOKEN"
The owner and admin roles grant both scopes, and member and viewer grant only products:read. If the token request fails with invalid_scope, its error_description names the scope your client isn't assigned: leave it out, or ask whoever created the client, or Neobits.
Your tenant's tokens are signed with your tenant's own keys, published at /.well-known/jwks.json on your tenant's host. Neobits APIs validate the tokens they receive. If your own services also verify Neobits tokens, use the published keys:
jwks_uri and issuer from /.well-known/openid-configuration./.well-known/jwks.json, and cache it no longer than its Cache-Control: max-age.kid matches the kid in the token header, and verify the RS256 signature.iss equals the issuer, aud contains your resource, and exp is in the future.If a token has a kid that is not in your cached key set, fetch the key set again before rejecting the token. Never hard-code a key. You can also check a token with the /v1/oauth2/introspect endpoint instead of verifying it yourself.
Neobits generates and holds your tenant's keys: a private key is never sent to or returned by the API. The key set can hold several keys. When Neobits replaces a key, the new one is published at least an hour before it signs, and tokens signed with the keys still in the set keep verifying.