The OAuth 2.0 Grant Type client_credentials

The current OAuth 2.0 specification defines different grant types for requesting and exchanging credentials, user data, and access rights between the parties involved. The OAuth2 grant “client_credentials” provides a special, simplified form of access control for clients such as the data storage service Dropbox. The difference from the other grant types is that the customer’s credentials are used only for the client access itself.

Whenever a user wants to use a special or secured client service, the provider asks the user to enter their user data. The familiar procedure of a secured sign-in with a service such as Facebook or Google is omitted entirely here. A redirect to an authorization server is therefore not necessary in this first step. The client permission is nevertheless very similar to the grant type “authorization,” with the difference that in this process only the customer’s credentials are used to request an access token.

The Authorization in Detail

Compared with the other OAuth2 grant types, only the customer data for the user sign-in is transmitted to the security server after a user authorization. The credential thus uses a greatly simplified and lean authorization procedure. This procedure is generally applied to a provider’s own client services in order to give a user who is already signed in access to special or extended services. The following two procedures describe the difference from the grant type “authorization.”

  • If, for example, you sign in to Dropbox with your Google account for the first time, you are redirected to Google’s authorization server and forwarded to an input dialog there. In this dialog you can authenticate with your username and password. If the login was successful, you are redirected back to the Dropbox website and cleared for use with an access token.
  • If you are already signed in to Dropbox with your Google account but want to perform a special user action in a protected area of Dropbox, Dropbox greets you with a user login dialog and thereby performs an additional check of your identity. Only when you enter and confirm your username and password does Dropbox send an authorization request to Google and request a valid access token directly. Once it has been released, you can perform the user action immediately.

Protocol and Process Steps in the Auth Flow

The simplified authorization procedure with the grant type “client_credentials” is particularly well suited to the “internal” identification of a user. In the case of Dropbox, the client asks for the user’s login credentials directly through a sign-in or approval dialog. The following parties are involved in this authentication sequence.

  • The user who is already logged in to the client (Dropbox in this example) and wants to perform a special access.
  • The client (Dropbox itself in this example), which can grant its users specially secured actions or access.

At this point, the authorization for an exemplary secured file access in Dropbox can still be implemented without a query to the security server. Only after the credentials have been confirmed is an additional external authorization process initiated as follows.

  • After the user credentials have been entered, the client (Dropbox in this example) forms a security request for the user’s authorization server. As a rule, the parameters “grant_type,” “client_id,” “client_secret,” and “scope” are transmitted with the request.
  • In addition to information such as username and password, Dropbox adds its own client information to the request.
  • The authorization server (Google in this example, as part of the user sign-in) checks the details of the user and of the client (Dropbox in this example) and issues a valid access token after successful authentication. The JSON object generally contains the parameters “token_type,” “expires_in,” and “access_token.”
  • The access token is sent to Dropbox and thereby authorizes the user to access the secured Dropbox services.

Convenience with Sufficient Security

In the example shown here, the provider Dropbox can use the grant type “client_credentials” to obtain a simplified authorization of its user quickly and securely. This form of server-to-server communication is used whenever the client (Dropbox here) is itself the owner of a resource or service and no explicit, delegated authorization by the resource owner (Google here) is necessary.

The simplified user authorization process therefore needs no additional prior authorization request and, with sufficient encryption, also provides appropriate security. It should be noted at this point, however, that no refresh token should be used here.

Share LinkedIn X Email