API Explorer

Consumer Grant Types

Consumer Grant Types

A Consumer's grant types control how tokens can be obtained through the Consumer. They say whether people can log in through it, whether the application can get a token for itself, or both.

A person "logs in through a Consumer" when they get a token with that Consumer's client id or key. They can do this by an OAuth2 login, by DirectLogin, or by renewing such a login. The token then names both the person and the application.

Grant types are optional. A Consumer that has no grant types set can be used in every way, as before.

Grant types only control how tokens are obtained. What the application may do with a token depends on the Scopes its Consumer holds.

Why set them

Some applications both log people in and get tokens for themselves. Such an application can use two Consumers: one for people logging in, and one for the application itself. If one Consumer's secret leaks, only one of the two uses is exposed. Each Consumer holds only the Scopes it needs, and metrics show people's calls and the application's calls separately.

Values

  • authorization_code: people log in through an OAuth2 / OpenID Connect provider, such as OBP-OIDC or Keycloak.
  • refresh_token: such a login can be renewed. Requires authorization_code.
  • client_credentials: the application gets a token for itself.
  • direct_login: people log in with DirectLogin.

Examples

Only client_credentials:

  • The application can get a token for itself through the Consumer.
  • People cannot log in through it, by OAuth2 or by DirectLogin.

authorization_code, refresh_token and direct_login, without client_credentials:

  • People can log in through the Consumer.
  • The application cannot get a token for itself through it. So it cannot act on its own through this Consumer.

Where they are checked

Grant types are checked twice:

  1. When a token is requested. DirectLogin is blocked for a Consumer whose grant types do not include direct_login: logging in with its consumer key fails. OBP-OIDC, and Keycloak through OBP's client storage, refuse to issue a token for a grant type that is not included.
  2. When a token is used. OBP-API refuses a call through the Consumer that its grant types do not allow, wherever the token came from. This also catches tokens issued before the grant types were set.

Who sets them

An administrator sets a Consumer's grant types. OBP never works them out from other settings, such as the Scopes the Consumer holds or whether it is a Platform App (see here). So granting a Consumer a new Scope never changes how it can be used.

Endpoints

  • Get Consumer Grant Types: GET /obp/v7.0.0/management/consumers/CONSUMER_ID/grant-types
  • Update Consumer Grant Types: PUT /obp/v7.0.0/management/consumers/CONSUMER_ID/grant-types, with the Role CanUpdateConsumerGrantTypes. Sending an empty list removes them, so the Consumer can again be used in every way.