Búsquedas recientes


No hay búsquedas recientes

Blog Beginner's Avatar

Blog Beginner

Incorporación 12 mar 2022

·

Última actividad 25 mar 2022

Seguimientos

0

Seguidores

0

Actividad total

10

Voto

1

Suscripciones

4

RESUMEN DE LA ACTIVIDAD

Última actividad de Blog Beginner

Blog Beginner creó una publicación,

Publicación Developer - Zendesk Apps Framework (ZAF)

Hello Community, 

I have following flow:

1) Defined a client id and secret in the manifest.json

2) client_secret parameter is defined as secure type in the manifest.json

3) Used the client.request() and {{setting.client_id}} syntax to fetch the secure type parameter value

4) The secure type parameter is used to fetch an access token using an API call 

5) Now I need to access the access token from the response object to call another API. However this fails. When I try to access the response object from step 4 it returns undefined

Following are my 2 calls 

const oAuthResponse = await client.request({
      type: 'POST',
      url: "https://api-m.paypal.com/v1/oauth2/token",
      contentType: 'application/json',
      headers: { "Authorization": "Basic {{setting.client_secret}}", "Accept": "application/json"},
      data: 'grant_type=client_credentials',
      cors: false,
      secure: true,
      httpCompleteResponse: true
    }
  ).then(function(data) {
      console.log('...oAuthResponse', data);
      return data['access_token'];
  });
const fetchTransResponse = await client.request({
      type: METHOD_GET,
      url: url,
      contentType: 'application/json',
      headers: { "Authorization": "Bearer "+oAuthResponse},
      cors: false,
      secure: true,
      httpCompleteResponse: true
    }
  ).then(function(data) {
      console.log(data);
      return data;
  });

Please note that the second call works absolutely fine when I hardcode the access token. 

Also the first call is working fine. I have validated that. 

 

Publicado 25 mar 2022 · Blog Beginner

0

Seguidores

3

Votos

1

Comentario


Blog Beginner hizo un comentario,

Comentario de la comunidad Developer - Zendesk Apps Framework (ZAF)

This worked with the following code. 

const oAuthResponse = await client.request({
      type: 'POST',
      url: "https://api-m.paypal.com/v1/oauth2/token",
      contentType: 'application/json',
      headers: { "Authorization": "Basic {{setting.client_secret}}", "Accept": "application/json"},
      data: 'grant_type=client_credentials',
      cors: false,
      secure: true,
      httpCompleteResponse: true
    }
  ).then(function(data) {
      console.log('...oAuthResponse', data);
      return data;
  });

So the data field should have been text instead of JSON. 

Ver comentario · Publicado 25 mar 2022 · Blog Beginner

0

Seguidores

1

Voto

0

Comentarios


Blog Beginner creó una publicación,

Publicación Developer - Zendesk Apps Framework (ZAF)

Hello Experts,

I am developing a Zendesk sidebar app to interact with my Paypal account. Following are the steps I am following

1) Created a Zendesk sidebar app

2) Call the Paypal API to fetch the access token using client_id and client_secret

3) Use Paypal rest APIs to do further business logic implementation

The requirement here is that I want my client_secret to be secure and not accessible to anyone. So what I did is created a "client_id:client_secret" string. Encoded it using btoa manually and stored the resulting string as a secure parameter in the manifest.json

Now when I try to access the secure parameter, I am getting an error. Following is my code snippet

const oAuthResponse = await client.request({
        url: "https://api-m.paypal.com/v1/oauth2/token",
        headers: { "Authorization": "Basic {{setting.client_secret}}" },
        secure: true,
        type: 'POST',
        contentType: 'application/json',
        data: JSON.stringify({ 'grant_type': 'client_credentials'})
      }
    ).then(function(data) {
        console.log(data);
        return data;
    });

It gives me the following error.

responseText"Proxy error: Invalid request"
status400

 Is there something I am doing incorrectly ?

Publicado 25 mar 2022 · Blog Beginner

0

Seguidores

3

Votos

4

Comentarios


Blog Beginner hizo un comentario,

Comentario de la comunidad Developer - Zendesk APIs

@mccabe.tonna I am unable to get the value of a custom field. Following is the code I wrote. Is there something I am doing incorrectly ?

I have tried all possible ways but no luck. Basically I want to read value from one custom field and set it to another custom field. It works fine when I try to assign hardcoded string. But the get part somehow isn't fetching the field information.  

 

const client = ZAFClient.init();

const getAccountName = document.getElementById('get-account-name-button')

const getAccountNameFunc = async () => {
  //let myData = client.get('ticket.customField:custom_field_4614118609940')
  let myData = client.get('ticketFields:custom_field_4614118609940')
  //let myData = client.get('ticketFields')
  //client.get(['ticket.customField:custom_field_4590824941204']).then(function(data){
let myString = JSON.stringify(myData);
client.set('ticket.customField:custom_field_4731199018772', myString)
}
client.on('app.registered', function () {
});
getAccountName.addEventListener('click', getAccountNameFunc);

Ver comentario · Publicado 12 mar 2022 · Blog Beginner

0

Seguidores

0

Votos

0

Comentarios


Blog Beginner creó una publicación,

Publicación Developer - Zendesk APIs

Following is my code snippet. 

 

const getAccountNameFunc = async () => {

const myData = client.get('ticket.customField:custom_field_4590824941204')
client.set('ticket.customField:custom_field_4731199018772', myData['ticket.customField:custom_field_4590824941204'])

}

Am I doing something wrong ? I think the client.get returns an object. But I am not able to use the data received to set the value of another field. 

Publicado 12 mar 2022 · Blog Beginner

0

Seguidores

2

Votos

1

Comentario