Replace node.js code with a inbuilt apigee policy

risinha
Participant I

Hello,

I have a node js code to which calls a target service by passing username and password getting a token then hitting the URL by passing that token in the header.

How can replace this piece of code with a policy in apigee ? What are my options ? Has anyone done this before.

0 2 127
2 REPLIES 2

You could create a proxy with a target endpoint based on the URL.

On the request flow, add a service callout to the URL passing username/password to obtain the token, then add the token in a header to your request.

Sounds like 2 things are happening:

  • get a token
  • use the token to call a different system

The "get a token" can be performed with the ServiceCallout. Check the docs for that.

The "use the token" is just a target endpoint in Apigee Edge. You may have to use AssignMessage to set the token in just the right way.

This proxy shows the technique in some detail. It uses the cache to store the retrieved token after the ServiceCallout.