Recent searches
No recent searches

Blog Beginner
Joined Mar 12, 2022
·
Last activity Mar 25, 2022
Following
0
Followers
0
Total activity
10
Vote
1
Subscriptions
4
ACTIVITY OVERVIEW
BADGES
ARTICLES
POSTS
COMMUNITY COMMENTS
ARTICLE COMMENTS
ACTIVITY OVERVIEW
Latest activity by Blog Beginner
Blog Beginner created a post,
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.
Posted Mar 25, 2022 · Blog Beginner
0
Followers
3
Votes
1
Comment
Blog Beginner commented,
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.
View comment · Posted Mar 25, 2022 · Blog Beginner
0
Followers
1
Vote
0
Comments
Blog Beginner created a post,
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"
status: 400
Is there something I am doing incorrectly ?
Posted Mar 25, 2022 · Blog Beginner
0
Followers
3
Votes
4
Comments
Blog Beginner commented,
@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);
View comment · Posted Mar 12, 2022 · Blog Beginner
0
Followers
0
Votes
0
Comments
Blog Beginner created a post,
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.
Posted Mar 12, 2022 · Blog Beginner
0
Followers
2
Votes
1
Comment