Obtain and cache Oauth2 token for outbound target endpoints

Hello I am new to apigee and I have a test working where I created a proxy secured by an apikey that will call my hosted API secured by OAuth2. It works now because I'm cheating and passing in the auth headers when I call the proxy and those pass thought.I want to upgrade the proxy to retrieve the token from my IDP /token endpoint using the client_credentials flow, cache it for later use, and use the token to call my outbound endpoint. At this point I'm looking for an ideal of how to get started. Can I use policies/steps or do I need to write a custom script?

0 1 177
1 REPLY 1

Yes, using policies (and conditions on them) will get you there.

1) LookupCache to retrieve the token.

2) If not found in cache: ServiceCallout to your /token endpoint and PopulateCache