Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Adding custom attributes to access token using SetOAuthV2Info policy not working

Hi

I have an access token which already has two custom attributes - email and profile. Now in one of the subsequent proxy calls , I need to add another attribute called username to the access token. This is returned in a json response of the specific proxy call. So in the response I have a Extract variable policy which extracts the value

<JSONPayload>
  <Variable name="username">
    <JSONPath>$.user.username</JSONPath>
  </Variable>
</JSONPayload>

This policy is working fine.

Now I am trying to add this to the access token using a SetOAuthV2Info policy and this is giving me Execution error at the policy.

<SetOAuthV2Info name="Set-OAuth-v20-Info-1"> 
  <DisplayName>Set OAuth v2.0 Info-1</DisplayName> 
  <AccessToken ref="request.header.authorization"/> 
  <Attributes> 
    <Attribute name="username" ref="username"/> 
  </Attributes> 
</SetOAuthV2Info>

I have tried all possible ways. Even when I set a hard coded value, it still gives me execution error.

So I have also tried setting a hard coded value - "test" to it and it still does not work

  <SetOAuthV2Info name="Set-OAuth-v20-Info-1"> 
    <DisplayName>Set OAuth v2.0 Info-1</DisplayName> 
    <AccessToken ref="request.header.authorization"/> 
    <Attributes> 
      <Attribute name="username">test</Attribute> 
    </Attributes> 
  </SetOAuthV2Info>

I am not sure where I am making an error.

@Dino @Dino-at-Google

0 15 1,318
15 REPLIES 15