Vor Kurzem aufgerufene Suchen


Keine vor kurzem aufgerufene Suchen

Ismail Faizi's Avatar

Ismail Faizi

Beigetreten 18. Nov. 2022

·

Letzte Aktivität 18. Nov. 2022

Folge ich

0

Follower

0

Gesamtaktivitäten

6

Stimme

1

Abonnement

1

AKTIVITÄTSÜBERSICHT

Neueste Aktivität von Ismail Faizi

Ismail Faizi hat einen Kommentar hinterlassen

Community-Kommentar Developer - Zendesk Apps Framework (ZAF)

Very interesting Sal. Are you using zat or zcli? I'm using zat and here the installationId is 0 locally.

Kommentar anzeigen · Gepostet 18. Nov. 2022 · Ismail Faizi

0

Follower

1

Stimme

0

Kommentare


Ismail Faizi hat einen Kommentar hinterlassen

Community-Kommentar Developer - Zendesk Apps Framework (ZAF)

For anyone having this issue. The following is working both locally and when installed:

    const metadata = await client.metadata();
  const apiUrl = metadata.settings.apiUrl;
  const settings = {
      url: 'https://' + apiUrl + '/' + path + (queryParams ? '?' + queryParams : ''),
      secure: !!metadata.installationId,
      cors: false,
      type: 'GET',
      dataType: 'json',
      contentType: 'application/json',
      headers: {
          Authorization: `Basic ${ !!metadata.installationId ? '{{setting.apiToken}}' : metadata.settings.apiToken }`,
      },
      accepts: "application/json",
  };
  return client.request(settings)
      .then(successHandler)
        .catch(handleFailure);

The `installationId` will be `0` when the app is running locally.

 

Kommentar anzeigen · Gepostet 18. Nov. 2022 · Ismail Faizi

0

Follower

1

Stimme

0

Kommentare


Ismail Faizi hat einen Kommentar hinterlassen

Community-Kommentar Developer - Zendesk Apps Framework (ZAF)

Thank you for your answer Ahmed Zaid. That is very unfortunate. Do you know whether there is a way to find out whether the app is running locally? Knowing so will allow me to make an "insecure" request locally and use secure settings when it is not local.

Kommentar anzeigen · Gepostet 18. Nov. 2022 · Ismail Faizi

0

Follower

0

Stimmen

0

Kommentare


Ismail Faizi hat einen Kommentar hinterlassen

Community-Kommentar Developer - Zendesk Apps Framework (ZAF)

Hello,

I'm experiencing this issue in a Zendesk support app where I need to use a third-party API requiring HTTP Basic authentication. The issue is so far only locally and I've not yet tried to install the app. The following is code that makes the request:

    const metadata = await client.metadata();
  const apiUrl = metadata.settings.apiUrl;
  const settings = {
      url: 'https://' + apiUrl + '/' + path + (queryParams ? '?' + queryParams : ''),
      secure: true,
      cors: false,
      type: 'GET',
      dataType: 'json',
      contentType: 'application/json',
      headers: {
          Authorization: 'Basic {{setting.apiToken}}',
      },
      accepts: "application/json",
    };

  return client.request(settings)
      .then(successHandler)
        .catch(handleFailure);

And this is how my `menifet.json` look like:

{
  "name": "...",
  "author": {
      "name": "...",
      "email": "...",
      "url": "..."
  },
  "defaultLocale": "da",
  "private": true,
  "location": {
      "support": {
          "nav_bar": "assets/index.html"
      }
  },
  "version": "0.9.12",
  "frameworkVersion": "2.0",
  "domainWhitelist": ["{{setting.apiUrl}}"],
  "parameters": [
      {
          "name": "apiUrl",
          "type": "url",
          "required": true,
          "secure": false,
          "default": "..."
      },
      {
          "name": "apiToken",
          "type": "password",
          "required": true,
          "secure": true,
          "default": "..."
      }
  ]
}
This is not a new app. I'm changing the API endpoints in an existing app.
 
Best regards,
Ismail

Kommentar anzeigen · Gepostet 18. Nov. 2022 · Ismail Faizi

0

Follower

0

Stimmen

0

Kommentare