async showPicker() {
    const pickerLib = await this._gapiPicker;
    let accessToken;
    try {
      accessToken = await this._authorizeDriveAccess();
    } catch (err) {
      if (err.error === 'popup_closed_by_user') {
        throw new PickerCanceledError();
      } else if (err.error) {
        // Error returned by the Google API client (not an instance of `Error`)
        throw new Error(err.error);
      } else {
        throw err;
      }
    }

    /** @type {(doc: PickerDocument) => void} */
    let resolve;

    /** @type {(e: Error) => void} */
    let reject;

    /**
     * @param {object} args
     *   @param {string} args.action
     *   @param {PickerDocument[]} args.docs
     */
    function pickerCallback({ action, docs }) {
      if (action === pickerLib.Action.PICKED) {
        const doc = docs[0];
        // nb. It would be better to get this URL from Google Drive instead of
        // hardcoding it if possible.
        const url = new URL('https://drive.google.com/uc');
        url.searchParams.append('id', doc.id);
        url.searchParams.append('export', 'download');
        if (doc.resourceKey) {
          url.searchParams.append('resourcekey', doc.resourceKey);
        }
        resolve({ id: doc.id, name: doc.name, url: url.toString() });
      } else if (action === pickerLib.Action.CANCEL) {
        reject(new PickerCanceledError());
      }
    }

    const view = new pickerLib.View(pickerLib.ViewId.DOCS);
    view.setMimeTypes('application/pdf');
    const picker = new pickerLib.PickerBuilder()
      .addView(view)
      .addView(new pickerLib.DocsUploadView())
      .setCallback(pickerCallback)
      .setDeveloperKey(this._developerKey)
      .setMaxItems(1)
      .setOAuthToken(accessToken)
      .setOrigin(this._origin)
      .build();
    picker.setVisible(true);

    return new Promise((resolve_, reject_) => {
      resolve = resolve_;
      reject = reject_;
    });
  }
/**
   * Show the Google file picker and return the document ID and
   * URL of the selected file.
   *
   * @return {Promise<{ id: string, name: string, url: string }>}
   *   Document ID, filename and download URL of the selected file.
   *   The download URL is only available by users who have access to the file.
   *   To make it accessible to everyone, use `enablePublicViewing`.
   */
Show the Google file picker and return the document ID and
URL of the selected file.

@return {Promise<{ id: string, name: string, url: string }>}
Document ID, filename and download URL of the selected file.
The download URL is only available by users who have access to the file.
To make it accessible to everyone, use `enablePublicViewing`.
Show the Google file picker and return the document ID and URL of the selected file . @return { Promise< { id : string name : string url : string } > } Document ID filename and download URL of the selected file . The download URL is only available by users who have access to the file . To make it accessible to everyone use ` enablePublicViewing ` .
async showPicker() {
    const pickerLib = await this._gapiPicker;
    let accessToken;
    try {
      accessToken = await this._authorizeDriveAccess();
    } catch (err) {
      if (err.error === 'popup_closed_by_user') {
        throw new PickerCanceledError();
      } else if (err.error) {
        throw new Error(err.error);
      } else {
        throw err;
      }
    }
    let resolve;
    let reject;
    function pickerCallback({ action, docs }) {
      if (action === pickerLib.Action.PICKED) {
        const doc = docs[0];
        const url = new URL('https://drive.google.com/uc');
        url.searchParams.append('id', doc.id);
        url.searchParams.append('export', 'download');
        if (doc.resourceKey) {
          url.searchParams.append('resourcekey', doc.resourceKey);
        }
        resolve({ id: doc.id, name: doc.name, url: url.toString() });
      } else if (action === pickerLib.Action.CANCEL) {
        reject(new PickerCanceledError());
      }
    }
    const view = new pickerLib.View(pickerLib.ViewId.DOCS);
    view.setMimeTypes('application/pdf');
    const picker = new pickerLib.PickerBuilder()
      .addView(view)
      .addView(new pickerLib.DocsUploadView())
      .setCallback(pickerCallback)
      .setDeveloperKey(this._developerKey)
      .setMaxItems(1)
      .setOAuthToken(accessToken)
      .setOrigin(this._origin)
      .build();
    picker.setVisible(true);
    return new Promise((resolve_, reject_) => {
      resolve = resolve_;
      reject = reject_;
    });
  }
async showPicker ( ) { const pickerLib = await this . _gapiPicker ; let accessToken ; try { accessToken = await this . _authorizeDriveAccess ( ) ; } catch ( err ) { if ( err . error === 'popup_closed_by_user' ) { throw new PickerCanceledError ( ) ; } else if ( err . error ) { throw new Error ( err . error ) ; } else { throw err ; } } let resolve ; let reject ; function pickerCallback ( { action , docs } ) { if ( action === pickerLib . Action . PICKED ) { const doc = docs [ 0 ] ; const url = new URL ( 'https://drive.google.com/uc' ) ; url . searchParams . append ( 'id' , doc . id ) ; url . searchParams . append ( 'export' , 'download' ) ; if ( doc . resourceKey ) { url . searchParams . append ( 'resourcekey' , doc . resourceKey ) ; } resolve ( { id : doc . id , name : doc . name , url : url . toString ( ) } ) ; } else if ( action === pickerLib . Action . CANCEL ) { reject ( new PickerCanceledError ( ) ) ; } } const view = new pickerLib . View ( pickerLib . ViewId . DOCS ) ; view . setMimeTypes ( 'application/pdf' ) ; const picker = new pickerLib . PickerBuilder ( ) . addView ( view ) . addView ( new pickerLib . DocsUploadView ( ) ) . setCallback ( pickerCallback ) . setDeveloperKey ( this . _developerKey ) . setMaxItems ( 1 ) . setOAuthToken ( accessToken ) . setOrigin ( this . _origin ) . build ( ) ; picker . setVisible ( true ) ; return new Promise ( ( resolve_ , reject_ ) => { resolve = resolve_ ; reject = reject_ ; } ) ; }
Show the Google file picker and return the document ID and
 URL of the selected file.
Show the Google file picker and return the document ID and URL of the selected file .
// Error returned by the Google API client (not an instance of `Error`) /** @type {(doc: PickerDocument) => void} */ /** @type {(e: Error) => void} */ /**
     * @param {object} args
     *   @param {string} args.action
     *   @param {PickerDocument[]} args.docs
     */ // nb. It would be better to get this URL from Google Drive instead of // hardcoding it if possible.