Share via

How to protect APIM MCP with OAuth 2.0

Naman Jain 40 Reputation points
2026-02-06T14:52:00.5166667+00:00

According to the documents their is no other setup required but when we check from vs code it migrate to <apim-url>/authorize.

So what are the steps to secure MCP Sever / Rest API uing APIM OAuth 2.0

Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.

{count} votes

1 answer

Sort by: Most helpful
  1. Siddhesh Desai 4,030 Reputation points Microsoft External Staff Moderator
    2026-02-06T16:57:51.7966667+00:00

    Hi @Naman Jain

    Your JSON Structure looks correct. VS Code / MCP does not acquire tokens, it only sends headers. So, you must paste the Bearer token explicitly.

    How You Get {access_token} (Outside VS Code)

    Option 1: Using Postman (Recommended for Testing)

    POST
    https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
    

    Body (x-www-form-urlencoded):

    client_id=<client-id>
    client_secret=<client-secret>
    grant_type=client_credentials
    scope=api://<api-app-id>/.default
    

    Response:

    {
      "access_token": "xxxxxxxxxxxxxxx"
    }
    

    Option 2: Using Script (curl example)

    curl -X POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token \
      -H "Content-Type: application/x-www-form-urlencoded
    

    If the resolution was helpful, kindly take a moment to click on 210246-screenshot-2021-12-10-121802.pngand click on Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

Your answer

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