From 6e95a9998996bced51beb3b0ca5b5cb05b6a84f0 Mon Sep 17 00:00:00 2001 From: Himanshu Kansal Date: Tue, 22 Apr 2025 14:37:47 +0530 Subject: [PATCH] Create Get OAuth2 access token from AAD using MI and forward it to the backend.policy.xml --- ...I and forward it to the backend.policy.xml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 examples/Get OAuth2 access token from AAD using MI and forward it to the backend.policy.xml diff --git a/examples/Get OAuth2 access token from AAD using MI and forward it to the backend.policy.xml b/examples/Get OAuth2 access token from AAD using MI and forward it to the backend.policy.xml new file mode 100644 index 0000000..fbdec52 --- /dev/null +++ b/examples/Get OAuth2 access token from AAD using MI and forward it to the backend.policy.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @($"{(string)context.Variables["authoization-Server"]}/{(string)context.Variables["tenantId"]}/oauth2/v2.0/token") + POST + + application/x-www-form-urlencoded + + @{ + return $"client_id={(string)context.Variables["clientId"]}&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion={(string)context.Variables["client_assertion"]}&grant_type=client_credentials&scope={(string)context.Variables["resource"]}/.default"; + } + + (); + return responseBody["access_token"].ToString(); + }" /> + + + @{ + return $"Bearer {(String)context.Variables["token"]}"; + } + + + + + + + + + + + + + +