Authenticate a server-to-server application
Use this flow for one server calling an API that accepts SyAuth OAuth access tokens. This grant represents the client, not a signed-in user.
This is an integration guide for developers. If your goal is to try a person's login screen, use the manual hosted-login test instead. The request here prints a token in your terminal; no browser login or approval screen is expected. You can test token issuance without a finished app, but using that token requires a destination API that accepts it.
1. Prepare the client and destination API
After dashboard setup, open Applications in the intended workspace and create or configure a confidential OAuth client. Include client_credentials in its allowed grant types. Keep the secret on the calling server.
Decide which destination API you will call and which scopes it requires. Add those exact names to the client's allowed scopes. A scope name alone does not implement permission checks; the destination API must validate the access token and enforce the permission.
2. Request an access token
| Placeholder | Where to get it |
|---|---|
YOUR_CONFIDENTIAL_CLIENT_ID | The confidential application's client_id, not its resource id |
YOUR_CLIENT_SECRET | The raw secret shown when the client is created or its secret is reset; a hidden/masked value is not usable |
YOUR_CONFIGURED_SCOPES | One or more exact scope names allowed on this client and accepted by the destination API, separated by spaces, for example orders:read orders:write only if you configured those names |
Replace the placeholders directly, keeping the surrounding quotes. Scope names are case-sensitive. For example, orders:read and read_orders are different names. No environment setup is required. Windows examples use Command Prompt (CMD).
- macOS / Linux
- Windows (CMD)
curl -i "https://api.syauth.com/e/v1/oauth/token/" \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode "client_id=YOUR_CONFIDENTIAL_CLIENT_ID" \
--data-urlencode "client_secret=YOUR_CLIENT_SECRET" \
--data-urlencode 'scope=YOUR_CONFIGURED_SCOPES'
curl.exe -i "https://api.syauth.com/e/v1/oauth/token/" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "grant_type=client_credentials" --data-urlencode "client_id=YOUR_CONFIDENTIAL_CLIENT_ID" --data-urlencode "client_secret=YOUR_CLIENT_SECRET" --data-urlencode "scope=YOUR_CONFIGURED_SCOPES"
Expect HTTP 200 with access_token, token_type and expires_in. Keep the actual access_token and lifetime from the response. Do not expect an application-user profile, ID token or refresh token from this grant. Request a new client-credentials token when needed.
HTTP 200 with those fields completes the token-issuance test. If the request returns one of the errors in the table below, correct the client settings or credentials before going on to step 3. Registering a client or getting this token does not create the destination API.
3. Call the destination API
Send Authorization: Bearer YOUR_OAUTH_ACCESS_TOKEN to an endpoint on the destination API, replacing the placeholder with access_token from step 2. Use that API's documented URL and method. There is no universal SyAuth resource endpoint for a permission such as orders:read.
The destination API must explicitly accept this token and enforce its scopes/audience. A client-credentials token does not authorize SyAuth workspace management: use a developer access token for /developer/.... See OAuth token operations.
| Error | Check |
|---|---|
invalid_client | Correct client_id, confidential client type, and the current raw secret |
unauthorized_client | client_credentials is enabled on this client |
invalid_scope | Every requested scope is in the client's allowed scopes; separate requested scopes with spaces |