​​run GCPapi through apigee & token as hder param

sidamore4
Participant I

HI I am new to apigee i have a jar which when executed using command java -jar usr/sid/edwi-auth-token.jar -u https://edwitestapi-iq734nlrra-de.a.run.app/getEdwiMarkerEvent gives a token that token passed as authorization and then hit google cloud api https://edwitestapi-iq734nlrra-de.a.run.app/getEdwiMarkerEvent how can i do this in apigee or if i can execute curl cmd directly by keeping jar that gives token somewher curl cmd -->curl -H "Authorization: Bearer $(java -jar /usr/sid/edwi-auth-token.jar -u https://edwitestapi-iq734nlrra-de.a.run.app/getEdwiMarkerEvent)" https://edwitestapi-iq734nlrra-de.a.run.app/getEdwiMarkerEvent.

Solved Solved
0 2 216
1 ACCEPTED SOLUTION

You cannot configure Apigee to run a curl command.

You cannot configure Apigee to execute an arbitrary jar. There is a way to configure Apigee to execute Java code, but you must package the code in the form of a "Java callout" which requires that you implement a specific interface, defined and documented by Apigee. (That option is what Christian King mentioned). Check the documentation to understand more details.

A better approach to your problem might be to step back and examine what the Java code does to get the auth token. What kind of auth token is it? Is it a JWT? If so you may be able to configure Apigee to generate the token for you using the GenerateJWT policy. If the existing java class does something else, then.... what? Maybe you can configure Apigee to do _that_, without relying on the jar or a curl command.

View solution in original post

2 REPLIES 2

You could always call the JAR directly using a JavaCallout

You cannot configure Apigee to run a curl command.

You cannot configure Apigee to execute an arbitrary jar. There is a way to configure Apigee to execute Java code, but you must package the code in the form of a "Java callout" which requires that you implement a specific interface, defined and documented by Apigee. (That option is what Christian King mentioned). Check the documentation to understand more details.

A better approach to your problem might be to step back and examine what the Java code does to get the auth token. What kind of auth token is it? Is it a JWT? If so you may be able to configure Apigee to generate the token for you using the GenerateJWT policy. If the existing java class does something else, then.... what? Maybe you can configure Apigee to do _that_, without relying on the jar or a curl command.