401 Invalid subscription key error with valid subscription key.

Sebastian Mennen 0 Reputation points
2023-06-22T07:49:12.96+00:00

I've set up an API which has JWT validation and subscription key enabled. I am seeing that around 10% of the requests made from one of the products assigned to the API are getting a 401 invalid subscription key error. I started logging the value of the ocp-apim-subscription-key header to verify that the requests which were being rejected actually had the right subscription key value and they do.
I've not been able to identify anything special about these requests that are being rejected.
Has anyone encountered the same problem? Any tips for what to investigate next?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,423 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 27,530 Reputation points Microsoft Employee Moderator
    2023-06-22T10:30:23.8733333+00:00

    @Sebastian Mennen Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are facing a 401 error code while accessing your API via APIM endpoint using valid subscription key.

    I hope you have verified if a correct subscription ID is being used against the API that's associated with the correct Product in your APIM setup. Please confirm.

    Troubleshooting steps for the 401 error message is documented here: Unauthorized errors (401) while invoking APIs. Please ensure that you have followed it.

    If it doesn't help. Could you please share the below details over email to azcommunity@microsoft.com with the below details:

    Subject : Attn Naveen

    Thread URL: Link to this thread.

    1. APIM Name
    2. Exact Time of the 401 issue in UTC.
    3. API Operation Name
    4. If you have the corresponding OCP-APIM traces that would also help. This article talks about OCP-APIM trace.

    This will help us to check the backend logs for the cause of 401 error.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.