To generate the needed tokens - consumer key, consumer secret, token ID, token secret - we are creating an integration, and access tokens, and assigning them to an employee with a specific role that has access to TBA. (Refer to https://medium.com/@morrisdev/netsuite-token-based-authentication-tba-342c7df56386)
Isn't it possible then, to get that employee's specific role, without little to no hassle?
I'm trying to do so, but I couldn't find a way, so I just started listing all possible employees and require that the person authenticating, other than supplying their 4 tokens (along with their account Id), to also supply their role, which seems stupid. (Once I have the employees, I can pretty much find the one with the needed role, granted they are the only one using it.)
private static void GetEmployees()
{
EmployeeSearch search = new EmployeeSearch();
EmployeeSearchBasic esb = new EmployeeSearchBasic();
esb.isInactive = new SearchBooleanField();
esb.isInactive.searchValue = false;
esb.isInactive.searchValueSpecified = true;
search.basic = esb;
SearchResult res = Client.Service.search(search);
res.pageSize = 2000;
res.pageSizeSpecified = true;
if (res.status.isSuccess)
{
Record[] searchRecords = res.recordList;
if (searchRecords != null && searchRecords.Length >= 1)
{
//Do something...
}
else
{
//Do something...
}
}
else
{
throw new Exception("Couldn't find any employees.");
}
}
The reason I'm searching for their role, is to make sure it has the needed permissions I'll be using. If I don't need their role to do this task, because it is again tied to the tokens in some way, please let me know how and I'll edit the context where needed.
I'm using the following webservices - https://webservices.netsuite.com/wsdl/v2017_2_0/netsuite.wsdl