0

create OAuth account

by admin
Published Aug 13, 2023
Script windmill
  • Submitted by admin Typescript (fetch-only)
    Created 565 days ago
    1
    /**
    2
     * create OAuth account
    3
     *
    4
     */
    5
    export async function main(
    6
      workspace: string,
    7
      body: {
    8
        refresh_token?: string;
    9
        expires_in: number;
    10
        client: string;
    11
        [k: string]: unknown;
    12
      }
    13
    ) {
    14
      const url = new URL(`${BASE_URL}/api/w/${workspace}/oauth/create_account`);
    15
    
    
    16
      const response = await fetch(url, {
    17
        method: "POST",
    18
        headers: {
    19
          "Content-Type": "application/json",
    20
          Authorization: "Bearer " + WM_TOKEN,
    21
        },
    22
        body: JSON.stringify(body),
    23
      });
    24
      if (!response.ok) {
    25
        const text = await response.text();
    26
        throw new Error(`${response.status} ${text}`);
    27
      }
    28
      return await response.text();
    29
    }
    30