0

I have the following inbound policy

<get-authorization-context 
provider-id="@(context.Request.Url.Query.GetValueOrDefault("authorizationProviderId"))" authorization-id="@(context.Request.Url.Query.GetValueOrDefault("authorizationId"))" context-variable-name="auth-context" 
ignore-error="false" 
identity-type="managed" />
<set-variable name="Test" value="{{((Authorization)context.Variables.GetValueOrDefault("auth-context"))}}" />

I have a named value pair created for authorizationId and I am trying to get the value for the authorizationId into a variable and use it later to control the flow and mock a response. For the above set of policies I am getting the following error when saving the policy as below

'auth-context' is an unexpected token. Expecting white space. Line 22, position 101.

I am trying to figure out the error, but unable to understand what is the issue. What could be the issue in the above policy statements?

My intention is to compare the value pair of authorizationId against a value and if it does not match I try to mock a response. Any other ways to achieve this would also be helpful for me

Ven
  • 83
  • 1
  • 5

1 Answers1

1

I have reproduced this issue at my environment with few modification in the policy and it worked as expected

Policy:

<inbound>
<base  />

<get-authorization-context  provider-id="@(context.Request.Url.Query.GetValueOrDefault("authorizationProviderId"))"  authorization-id="@(context.Request.Url.Query.GetValueOrDefault("authorizationId"))"  context-variable-name="auth-context"  ignore-error="false"  identity-type="managed"  />  
<set-variable  name="Test"  value="@(((Authorization)context.Variables.GetValueOrDefault("auth-context"))?.AccessToken)"  />

</inbound>

Test Output:

enter image description here

enter image description here

Trace:

enter image description here

enter image description here

enter image description here

enter image description here

You can refer to this ms docs for more details.

Ikhtesam Afrin
  • 897
  • 1
  • 1
  • 6