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

# Starts OAuth For Tiktok Account

> Open the API in a window with appropriate params and headers instead of using the Curl. User is navigated to Tiktok login OAuth screen. On successful login, listen on window object for message where e

Open the API in a window with appropriate params and headers instead of using the Curl. User is navigated to Tiktok login OAuth screen. On successful login, listen on window object for message where event listener returns data in its callback function.

### Sample code to listen to event data:

window\.addEventListener('message',
function(e) \{
if (e.data && e.data.page === 'social\_media\_posting') \{
const \{ actionType, page, platform, placement, accountId, reconnectAccounts } = e.data
}
},
false)

### Event Data Response:

\{
actionType: string,            Ex: "close"
page: string,                  Ex: "social-media-posting"
platform: string,              Ex: "tiktok"
placement: string,             Ex: "placement"
accountId: string,             Ex: "658a9b6833b91e0ecb8f3958"
reconnectAccounts: string\[]]   Ex: \["658a9b6833b91e0ecb834acd", "efd2daa9b6833b91e0ecb8f3511"]
}

### The accountId retrieved from above data can be used to fetch Tiktok account details using below API -

API: '/social-media-posting/oauth/tiktok/accounts/:accountId'

Method: GET

```http theme={null}
GET https://services.leadconnectorhq.com/social-media-posting/oauth/tiktok/start
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Query parameters

<ParamField query="locationId" type="string" required default="w37swmmLbA02zgqKPpxITe2">
  Account Id
</ParamField>

<ParamField query="userId" type="string" required default="u37swmmLbA02zgqKPpxITe2">
  User Id
</ParamField>

<ParamField query="page" type="string" default="integration">
  Page
</ParamField>

<ParamField query="reconnect" type="string" default="true">
  Reconnect
</ParamField>

## Respuestas

<Accordion title="200 - Successful Response" />

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET 'https://services.leadconnectorhq.com/social-media-posting/oauth/tiktok/start' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/social-media-posting/oauth/tiktok/start', {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
    },
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'GET',
      'https://services.leadconnectorhq.com/social-media-posting/oauth/tiktok/start',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
      },
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/social-media-posting/oauth/tiktok/start');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'GET',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
      ],
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
