Reputation: 181
I'm making a Node application that uses Zendesk API. Users logged in and can create tickets through my application.
To create tickets, I use this configuration
var config = {
method: 'post',
url: 'url/api/v2/requests.json',
headers: {
'Authorization': 'Bearer adminToken',
'X-On-Behalf-Of': 'emailOfUser',
'Content-Type': 'application/json',
},
data: ticket
};
axios(config)
.then(function (response) {
//My code
})
With X-On-Behalf-Of
I can create tickets for the user logged in with my admin token.
However, it doesn't work for updating the ticket with comments. I got a Forbidden error
. Here is my code :
var config = {
method: 'put',
url: 'url/api/v2/requests/' + idTicket,
headers: {
'Authorization': 'Bearer adminToken',
'X-On-Behalf-Of': 'emailOfUser',
'Content-Type': 'application/json',
},
data: { "request": { "comment": { "body": message, "public": true, "author_id": userId } } }
};
And when I remove the X-On-Behalf-Of
, the comment is publish, but with my name, the admin name, and not the user name.
Do you know a solution for that ?
Thanks
Upvotes: 0
Views: 493
Reputation: 412
It is likely that your token is missing impersonate
scope.
Example for authorization code grant:
https://{subdomain}.zendesk.com/oauth/authorizations/new?client_id=foo&redirect_uri=bar&scope=impersonate+write&response_type=code
Upvotes: 0