To do so, the user logs in to the admin interface, reviews the requested permissions and gives the application their consent. The application then receives an
access_token that contains only the granted permissions.
Supported methods
List of all supported methods.General
The authorization server follows OAuth 2.1 and supports only the authorization code flow with PKCE (methodS256). Clients are public clients: they do not authenticate at the token endpoint with a client secret, but solely via the code_verifier.
Flow
- The client retrieves the server metadata (
GET .well-known/oauth-authorization-server) and determines the URLs of the authorization and token endpoints from it. - The client redirects the user’s browser to
GET oauth/authorize. - The REST-API validates the request and redirects the browser to the consent page in the admin interface. If the user is not logged in, they log in first.
- On the consent page, the user selects the permissions they want to grant to the application and approves or denies the request.
- The browser is redirected back to the client’s
redirect_uri– with an authorization code (code) on approval, or with the erroraccess_deniedon denial. - The client exchanges the authorization code via
POST oauth/tokenfor anaccess_tokenand arefresh_token.
access_token received is sent in the X-Authorization header (see API basics).
Client registration
The client does not need to be registered in the shop beforehand. Theclient_id is an HTTPS URL at which the client provides a JSON document with its metadata (Client ID Metadata Document). The document must contain at least the fields client_id, client_name and redirect_uris. The value of client_id in the document must exactly match the URL from which the document is retrieved.
redirect_uri of an authorization request is compared exactly with the redirect_uris listed in the document. For loopback addresses (e.g. http://127.0.0.1/callback), only the port may differ.
Scopes
A scope corresponds to exactly one permission of a permission area and has the form<area>:<permission>, e.g. configuration:read. The available scopes are derived from the permissions that can be assigned to user accounts (see API reference user management) and are listed in the server metadata under scopes_supported.
A user can only grant scopes whose permissions they hold themselves. The issued access_token contains only the granted permissions, even if the user account has further permissions. The scope admin:active corresponds to full access and can only be granted by administrators.
Validity
The authorization request (parameterrequest of the consent page) is valid for 10 minutes, the authorization code for 1 minute. The authorization code can only be redeemed once. A refresh_token can also be used only once: each renewal issues a new refresh_token and invalidates the previous one.
Using the methods
GET .well-known/oauth-authorization-server
This endpoint returns the metadata of the authorization server according to RFC 8414. It is accessible without login.Example
Response
GET oauth/authorize
This endpoint is the entry point of the authorization flow. It is called by the user’s browser without login, validates the request and, on success, redirects to the consent page in the admin interface. The request is described via the query parametersresponse_type (always code), client_id, redirect_uri, code_challenge and code_challenge_method (always S256). Optionally, the requested scopes can be specified, separated by spaces, via the scope parameter. If scope is not specified, the user alone decides on the consent page which permissions are granted. The optional parameter state is returned unchanged to the client on redirect; the optional parameter resource is also taken over.
Example
Response
On success, the browser is redirected to the consent page of the admin interface:Error codes
GET oauth/authorize/{request}
This endpoint returns the details of a pending authorization request that are shown on the consent page. It is called by the admin interface and requires login.Example
Response
Error codes
POST oauth/authorize/{request}/approve
This endpoint approves a pending authorization request. It is called by the admin interface and requires login. An authorization code is created for the logged-in user account, and the URL to which the browser must be redirected back to the client is returned. The URL contains the parameterscode, state (if specified) and iss.
The granted scopes are passed in the request body. Only scopes that the client requested (or any, if the client requested none) and whose permissions the logged-in user account holds itself can be granted.
Example
Request body
Response
Error codes
POST oauth/authorize/{request}/deny
This endpoint denies a pending authorization request. It is called by the admin interface and requires login. No authorization code is created. The URL to which the browser must be redirected back to the client is returned. The URL contains the parametererror=access_denied as well as state (if specified) and iss.
Example
Request body
Response
Error codes
POST oauth/token
This endpoint issues anaccess_token and a refresh_token. It is accessible without login. Unlike the other REST API endpoints, it does not expect a JSON body but form-encoded parameters (application/x-www-form-urlencoded).
The grant_type parameter determines whether an authorization code is redeemed (authorization_code) or an existing token is renewed (refresh_token). When redeeming an authorization code, code, client_id, redirect_uri and code_verifier are passed in addition, where client_id and redirect_uri must match the original authorization request. When renewing, refresh_token and client_id are passed. A refresh_token is only accepted from the client it was issued to.
