wso2 / api-manager

All issues, tasks, improvements and new features of WSO2 API Manager
Apache License 2.0
34 stars 8 forks source link

"apictl get-keys" does not work when "required" custom attributes for applications have setup #849

Open wasuradananjith opened 4 years ago

wasuradananjith commented 4 years ago

Description: When you have added custom attributes for applications in the deployment.toml which are required, the get-keys does not work because it cannot create the application when generating keys.

Suggested Labels: Type/Bug Priority/Normal

Affected Product Version: 3.2.0

OS, DB, other environment details and versions: OS: Ubuntu 20.04 LTS

Steps to reproduce:

  1. Add a required custom attribute for applications as explained in [1].
  2. Start the server.
  3. Add an environment using apictl add-env and create an API from the UI (or import an API using apictl import-api)
  4. Generate keys for the API using apictl get-keys. You will receive an error as below. image

Note:- This behaviour is common when generating keys for API Products as well

Solution: This problem has arisen because currently when creating the default-ctl-app we pass a specific set of parameters. And those parameters do not contain the customized ones. Hence we need to create a new REST API to generate keys which contain a function that can check whether there are any customized attributes when creating a new application for the first time to generate keys.

[1] https://apim.docs.wso2.com/en/next/learn/consume-api/manage-application/advanced-topics/add-custom-attributes-to-applications/#add-custom-attributes-to-applications

wasuradananjith commented 3 years ago

When executing the get-keys command, the apictl will create an application named default-ctl-app. The above issue arises because the APIM was not able to create the default-ctl-app when the custom attributes are defined for applications in that particular APIM instance.

As a workaround, we can manually create an application named default-ctl-app for the particular user from the UI or using REST API. After that, if you execute the get-keys command you will not receive the above error since the application is already created and apictl only needs to generate keys using it.