最近搜索


没有最近搜索

client.request() secure parameter - Using the response



已于 2022年3月25日 发布

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. 

 


0

1

1 条评论

Hi Blog Beginner,

Thanks for reaching out!

Is this app installed in your Zendesk instance or are you testing this locally? Secure settings won't work if you're testing the app locally on the ZAT server. Here's an article that goes in to more detail:

If the app has been installed and you're still seeing these issues, let me know and we can look in to it further.

Thanks!

Tipene

0


登录以发表评论。

找不到所需的内容?

新建帖子