async setAccessToken()

in src/embed.ts [459:475]


  async setAccessToken(accessToken: string): Promise<void> {
    if (!accessToken) {
      throw new Error("Access token cannot be empty");
    }
    let embedType = this.config.type;
    embedType = (embedType === 'create' || embedType === 'visual' || embedType === 'qna') ? 'report' : embedType;
    try {
      const response = await this.service.hpm.post<void>('/' + embedType + '/token', accessToken, { uid: this.config.uniqueId }, this.iframe.contentWindow);

      this.config.accessToken = accessToken;
      this.element.setAttribute(Embed.accessTokenAttribute, accessToken);
      this.service.accessToken = accessToken;
      return response.body;
    } catch (response) {
      throw response.body;
    }
  }