Skip to main content
Nintex Community Menu Bar
Question

K2 Cloud: How to access K2 Cloud REST API from Okta Authentication

  • August 9, 2024
  • 0 replies
  • 17 views
  • Translate

Forum|alt.badge.img+3

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.Configuration["OktaAuthLocal:Domain"];
        options.ClientId = builder.Configuration["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

 

Did this topic help you find an answer to your question?

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings