How to enable token based authentication for scripted rest method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 03:26 PM - edited 02-28-2023 05:40 PM
Hello Everyone,
I am trying to figure out how i can enable token based authentication for scripted rest method. We already have the below scripted rest resource in use and we are trying to add token based authentication. Can someone please guide me through the process.
Oauth is not supported by the third party, they only have option to send auth data as token via URL. Please suggest a way how to enable the Token based authentication for inbound scripted Rest resource.
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
//todo
// #1 : identify the type of task
gs.info("webhooks" + JSON.stringify(request.body.data));
var Error = new sn_ws_err.ServiceError();
var payload = request.body.data;
// If there's no payload return an error.
if (global.JSUtil.isEmpty(payload))
return new sn_ws_err.BadRequestError("Payload is empty");
try {
if (request.body.data || request.body.data.fields || request.body.data.fields.issuetype.name) {
var pro = true;
var taskType = request.body.data.fields.issuetype.name;
if (taskType == "Initiative") {
pro = new global.MnAJiraDataImport().updateMAProject(request.body.data);
} else if (taskType == "Epic") {
pro = new global.MnAJiraDataImport().updateMAIssue(request.body.data);
} else if (taskType == "Story") {
pro = new global.MnAJiraDataImport().updateMATask(request.body.data);
}
if (pro == true) {
response.setStatus(200);
} else {
Error.setStatus(500);
Error.setMessage('Internal Server Errror');
Error.setDetail('Unable to Process the request ');
return Error;
}
}
} catch (ex) {
Error.setStatus(500);
Error.setMessage('Internal Server Errror');
Error.setDetail('Unable to Process the request ' + ex.toString());
return Error;
}
})(request, response);
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 04:23 PM - edited 02-28-2023 04:23 PM
Hello,
To clarify, do you mean an inbound web services request to your instance and so you want the client sending the request to use an access token (so OAuth)?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2023 04:56 PM - edited 02-28-2023 05:35 PM
@Allen Andreas Yes it is an inbound web services request. Oauth is not supported by the third party, they only have option to send auth data as token via URL.
Please suggest how i can enable the Token based authetication for this inbound.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 07:03 AM
Hi there, I have a very similar situation. Were you ever able to get this figured out?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2024 03:43 AM