{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
5

How to set a custom API key for a product ?  

  • Export to PDF
Arun Kumar created · Apr 17, 2015 at 11:28 PM · 2.4k Views · Dino edited · Dec 02, 2015 at 07:59 PM

There have been a few occasions in the past where keys have been accidentally deleted and there has been a requirement to recreate the same keys to restore traffic. In other cases, the requirement was to create a product with a specific API key which was used in a legacy system.

Following is the API call that will allow creating a custom key and adding it to the desired product:

curl -v -n -X POST \ 
   https://api.enterprise.apigee.com/v1/o/{Org}/developers/{Developer}/apps/{App}/keys/create \
  -H "Content-type: application/xml" \
  -d @text.xml

Where the contents of text.xml would be :

<CredentialRequest> 
  <Attributes/> 
  <ConsumerKey>key</ConsumerKey> 
  <ConsumerSecret>secret</ConsumerSecret> 
  <ApiProducts> 
    <ApiProduct>product</ApiProduct> 
  </ApiProducts> 
  <Scopes/> 
</CredentialRequest>

Note: The UI would continue to show the default key that was assigned when the product was added to the App. If you remove and add the product back to the App, you will notice the updated key reflected in the UI.

thub.nodes.view.add-new-comment
apikey
Add comment Show 5
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kevin ♦   · Jun 30, 2015 at 07:46 AM 0
Link

@Arun Kumar I tried your solution, but the key is added to an empty product:

{
    "apiProducts": [],
    "attributes": [],
    "consumerKey": "IwAWRqaIG9uA4fq3PEBfher3QbZY1bbG",
    "consumerSecret": "IRwhKr4CiCqGNbVF",
    "expiresAt": -1,
    "issuedAt": 1435654188772,
    "scopes": [],
    "status": "approved"
}

Anybody has an idea what I am doing wrong here?

avatar image Kevin ♦ Kevin ♦   · Jun 30, 2015 at 09:23 AM 2
Link

It seems to work when I make another call to "manually" add the API key to my Product:

curl -v -u admin@apigee.com -k https://api.enterprise.apigee.com/v1/organizations/{org_name}/developers/{developer_email}/apps/{app_name}/keys/IwAWRqaIG9uA4fq3PEBfher3QbZY1bbG -H "Content-Type: application/json" -d '{"apiProducts": ["MyAPIProduct"], "attributes" : []}'
avatar image Benjamin Goldman · Nov 18, 2015 at 03:22 PM 0
Link
@Arun Kumar

Any chance you can clarify the above in light of the information below?

avatar image Dhananjay D ♦ · Mar 07, 2017 at 06:36 PM 0
Link

If company is subscribed to app instead of developer subscribed to app you can use following API to create desired key and secret.

curl -v -n -u adminEmail:password -X POST \ 
   https://api.enterprise.apigee.com/v1/o/{Org}/companies/{Company-Name}/apps/{App}/keys/create \-H "Content-type: application/xml" \
  -d @text.xml

Content of text.xml would be same.

Once desired key and secret are in place and if there is need to revoke or remove old keys then that can be done using management UI.

avatar image Toshihiro Shibamoto ♦♦ · Mar 14, 2018 at 01:22 PM 0
Link

Hi @Floyd Jones, Could you follow this up in the Apigee Docs?

It seems that the API:
https://api.enterprise.apigee.com/v1/o/{Org}/companies/{Company-Name}/apps/{App}/keys/create
is missing from POST methods on:

https://apidocs.apigee.com/api/company-app-keys-0

Thanks,
Toshi

Article

Contributors

avatar image avatar image

Follow this article

11 People are following this .

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Navigation

How to set a custom API key for a product ?

Related Articles

New UI Features: View Key Expiry, Manage rotating keys, Revoke apps and developers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges