I am using Auth0 login for users to be able to login/authenticate in Okta then redirect to the custom application and i want to know if we can pass the user token id to K2 Cloud REST API to be able to access user’s Worklist/Tasks. Initially I tried using K2 OData to get the tasks however it takes too long to load the data as it load all records first before executing the filter based on the query string.
Account Controller:
public async Task Login(string returnUrl = "/")
{
var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
.WithRedirectUri(returnUrl)
.Build();
await HttpContext.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
}
Program.cs :
builder.Services.AddAuth0WebAppAuthentication(options =>
{
options.Domain = builder.ConfigurationD"OktaAuthLocal:Domain"];
options.ClientId = builder.Configurations"OktaAuthLocal:ClientId"];
}
K2 Cloud REST API that needs to be accessed:
https://.....com/api/workflow/v1/swagger/index#!/Tasks/GetTasks
Access K2 REST API from HTTP CLient:
HttpClient _client = new HttpClient();
_client.BaseAddress = new Uri("https://....onk2.com/api/workflow/v1/swagger/index#!/Tasks/GetTasks");
_client.DefaultRequestHeaders.Add("accept", "application/json;odata.metadata=none");
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", usertoken);
K2 OData Query:
https://...onk2.com/api/odatav4/v4/com_K2_System_Reports_SmartObject_AnalyticsTask?$top=10&$filter=Destination eq useremail