Connect your own account
Use the OAuth 2.0 client credentials grant for server-to-server access to your Middesk account without user sign-in. For access on behalf of a user, use the authorization-code flow.
Getting an access token
Create an OAuth client
Use your API key to create a confidential client with client_credentials enabled. These settings are available through the API.
Replace the example URI with a URL you control. A redirect URI is required to create the client, but this grant does not use it. Store the returned client_id and secret as CLIENT_ID and CLIENT_SECRET on your server. If you already have a client with this grant enabled, use its credentials.
Request a token
Send a form-encoded request using the client ID and secret as HTTP Basic Auth credentials.
Choose an access scope; if omitted, scope defaults to read_write. You can send client_id and client_secret in the form body instead of using Basic Auth.
The response uses the shared token fields and includes expires_in. Tokens expire after one hour by default. Use expires_in to determine when to request a new token. This grant does not issue refresh tokens.
Make an API request
Follow the shared API request example and token restrictions. Machine tokens also cannot invite or remove account users, create or remove affiliate users, or create, remove, or reinvite partner users.
Authenticating with a private key
If your integration uses private_key_jwt, send a signed JWT assertion in place of the client secret.
Create the client with token_endpoint_auth_method: "private_key_jwt" and jwks containing a keys array of public JSON Web Keys. The client must be confidential and allow client_credentials. Give each public key a unique kid and keep private keys on your server.
Use your JWT library to sign an assertion with these values:
Do not send a client secret with the assertion. Each assertion can be used once; the token response and API usage are the same as above.
Revoking access
Use the shared revocation request. For private_key_jwt, replace Basic Auth with client_assertion_type and a fresh client_assertion, using the same audience as the token request.
Disabling the grant or removing a signing key does not invalidate tokens already issued.