Dynamically pickup KVM depending upon consumer.

Let's imagine, I have

Consumer 1 - Salesforce

Consumer 2 - Google

Consumer 3 - Facebook,

These 3 consumers shares same target but having different credentials accounts for backend. And I have created one KVM for each consumer.

now the questions is - when Salesforce calls, Apigee has to identify the consumer (I can do by using API key) use respected key store values and call the backend server.

and repeat the same for other 2 consumers also.

Solved Solved
0 12 832
1 ACCEPTED SOLUTION

Not applicable

if you can identify the consumer with clientid then have the KVM key as clientid and value as the different credentials.

In the KVM policy use the reference of key to the clientid.

View solution in original post

12 REPLIES 12

Not applicable

if you can identify the consumer with clientid then have the KVM key as clientid and value as the different credentials.

In the KVM policy use the reference of key to the clientid.

Yes, this is the right idea. It looks like this in the policy:

<KeyValueMapOperations name='KVM-Get-1' mapIdentifier='nameOfMap'>
  <Scope>environment</Scope>
  <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
  <Get assignTo='variable.to.set'>
    <Key>
      <Parameter>upstream_credential</Parameter>
      <Parameter ref='client_id'/>
    </Key>
  </Get>
</KeyValueMapOperations>

if you set KVM key as client id (which is good), How do you set the password here ? how do you choose KVM from multiple KVM's dynamically ?

it will have multiple entries in one KVM.

Hi Priyadarshi,

Can I make "mapidentifier" dynamic like this ?

mapIdentifier="{verifyapikey.VerifyAPIKey.CliendId}"

No, you cannot use variable in place of mapidentifier.

In that case what you can do,

Key reference you can use apiproxy.name and in value you can put all its entries and values as a json body. You can try this.

Hi Priyadarshi.

Do you have any sample code for this please.

I want to use json body with proxy names(apiproxy.name)

You can use normal KVM get and in the variable json body will be available in flow. Then use extract variable policy to get all json key and values.

Else can use javascript policy also.

I got it now. Thanks.

Can it be slightly better to use something other than the client id as the KVM key, like a custom app attribute? Client id may change due to expiry or revocation, and if you use a custom attribute then you'd not need to update the KVM up on client id change.

Yes, you can have any custom attribute or name as key, it's totally as per your business case and how uniquely it's used.

If you expect the client id (aka API Key, aka consumer key) to change, You can use the "App id". This can remain the same, even as you rotate API keys. If you want to insulate yourself even from changes in the app, then you could use a separate identifier, a custom attribute that you would attach to each app, in the way you are imagining.