> ## Documentation Index
> Fetch the complete documentation index at: https://docs.link4sync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTPS with OAuth

> Get a short-lived token with your Link4Sync login and publish JSON over HTTPS.

Use this flow for backend services that run on behalf of your Link4Sync account. OAuth is documented for HTTPS only, so the token never travels unencrypted.

> [!TIP]
>
> For a service that should not hold your account password, create a producer
> [subaccount](https://docs.link4sync.com/en/manage/subaccounts.md) and get its token with client credentials instead. Accounts
> created with Google or Microsoft have no Link4Sync password and must use a subaccount.

## Before you start

Set these environment variables:

| Variable | Value |
| - | - |
| `LINK4SYNC_URL` | HTTPS URL from the topic card |
| `LINK4SYNC_EMAIL` | Your Link4Sync account email |
| `LINK4SYNC_PASSWORD` | Your Link4Sync account password |

## 1. Get an access token

```sh theme={null}
TOKEN=$(curl -s https://auth.link4sync.com/realms/link4sync/protocol/openid-connect/token \
  -d grant_type=password -d client_id=kafka-connect-access \
  --data-urlencode "username=$LINK4SYNC_EMAIL" \
  --data-urlencode "password=$LINK4SYNC_PASSWORD" | jq -r .access_token)
```

## 2. Publish an event

```sh theme={null}
curl -i -X POST "$LINK4SYNC_URL" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"temperature": 21.5}'
```

A successful publish returns **`202 Accepted`**.

> [!NOTE]
>
> The token expires. Request a new one when you get `401`.

> [!TIP]
>
> A service that should not hold your account password can use the topic's producer credential
> instead. See [HTTP(S) with SCRAM](https://docs.link4sync.com/en/publish/http-scram.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.