Unable to use OAuth to access K2 API - getting 401 Unauthorized response

  • 16 February 2021
  • 0 replies
  • 58 views

Userlevel 5
Badge +20
 

Unable to use OAuth to access K2 API - getting 401 Unauthorized response

kbt179986

PRODUCT
K2 Cloud
This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.

Issue

You are unable to use OAuth to access K2 API. You are unable to authenticate using OAuth2 when using K2 API, although everything appears to be configured correctly in K2 Management portal and AAD.

When testing with Postman, you are able to request a token for https://api.k2.com, but when making a call to https://KUID.onk2.com/api/odata/v3/ or https://KUID.onk2.com/api/Workflow/V1/workflows with the token in the header, you just receive a 401 Unauthorized response.

You are also unable to access K2 API using Swagger UI as it always gives a 401 Unauthorized error.

Symptoms

When making a call to https://KUID.onk2.com/api/odata/v3/ or https://KUID.onk2.com/api/Workflow/V1/workflows with the token in the header you receive a 401 Unauthorized response.

Resolution

This problem can appear when your OAuth URL does not have final forward slash, i.e. it looks as follows:

https://login.microsoftonline.com/70180fe3-a20c-4cc8-8d3e-b19594ba9274/oauth2/authorize?resource=https://api.k2.com

In this case adding "/" to the very end of this URL can resolve your problem.


0 replies

Be the first to reply!

Reply