Using management APIs to restore a deleted developer results in "ConsumerKey already exists"

Not applicable

I'm a cloud user and I'm writing code to backup products, developers, developers apps, and developer apps keys, and corresponding code to restore them.

If a developer has been deleted and I restore from backup to the same org, when the code calls the developer app keys create operation (http://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/developers/%7Bdeveloper_email_or_id%7D/apps/%7Bapp_name%7D/keys/create), I get the following response:

Status: 409
{
  "code" : "keymanagement.service.ConsumerKeyAlreadyExists",
  "message" : "ConsumerKey already exists",
  "contexts" : [ ]
}

Note that *the developer has been deleted* so that the consumerKey (api_key) definitely no longer exists. (Clearly if the developer has not been deleted then the error also occurs). I'm running the backup and restore tests on a trial instance for testing. It comes with one user (Nikola Tesla) and one app ("weatherapp").

In experimenting, Edge is remembering the previously used consumerKeys. This means that there is no way to restore a developer with the previously used key. So, upon accidental deletion of a developer or app, or a Cassandra problem (which we've had twice), that developer's app will be off-line until a new api_key can be assigned and distributed to all clients (a significant problem for mobile apps).

Is there some way to assign a consumerKey (api_key) that was previously used to restore a developer/developer app through the Management APIS?

1 8 921
8 REPLIES 8

@George Shaw, I'm seeing the same thing on my end. Let me check around and see what I can find out. Maybe there's an interval one has to wait before the old key gets cleared from the DB. Or maybe, to guarantee keys stay unique, restoring auto-generated keys just isn't allowed.

@George Shaw, relaying what I found out from Eng. Is CPS enabled on your org? (Do a Get Org API call if you don't know. If it is, you'll see features.isCpsEnabled = true.)

  • If you're *not* CPS, there's no auto-cleanup of deleted apps/keys.
  • If you're CPS, the auto-purge process could take ~24 hours.

CPS is enabled. I just delete the test user and will try to restore at intervals to see happens.

I just tried to restore a backup I made before making the original post (5 day ago). It still fails, so the ~24 hours autopurge does not seem to be working.

Same here. I'll check back with engineering.

Any more feedback from Eng? Is it possible to restore a key?

I'm running into this, too, I think -- trying to import developers into a new cluster (and taking a couple of tries to do it leaves the old keys in the "limbo" state). Any solution for this issue? (I don't have features.isCpsEnabled on my org, and my cluster is on-prem)

Hi @George Shaw - Was hoping to get a quick answer, but this may be a bug, so I've filed a ticket. Please feel free to open a support ticket, and reference MGMT-3730 as the open bug. Sorry we haven't been able to deal with this here.