Approve app for trusted companies and require approval for some companies.

Hello everyone. I have a requirement. I have a product A which requires approval after app registration. Now I have 2 companies. Company A and company B. If company A comes and develops app, it should automatically approve app instead of admin approving it. If company B creates an app then it should require approval from admin. So Far, I have been able to do half of it. I have created a database table where I have all the company names that don't require app approval. When a developer creates an app, my dev portal checks its company name from database and if it is present there then it does what is instructed next. The part where I am struggling is the app approval part. I check management api and I found a function in APIProduct class called 'setApprovalType($type)' but it doesn't seem to work. Can someone tell me what is the issue and how to do it?

Thank you,

Zohaib Masood.

0 6 221
6 REPLIES 6

If you make a call to get developer app detail on an existing app, you can that there is a status on the app, the the API Product, and the credentials. You can update an app or during create set any of those values to be "revoked" instead of "approved":

GET /o/{org}/developers/{email}/apps/{app_name}:

{
    ...
    
    "createdBy": "foo@example.com",
    "credentials": [
        {
            "apiProducts": [
                {
                    "apiproduct": "Product A",
                    "status": "approved"
                }
            ],
            "consumerKey": "xxxxx",
            "consumerSecret": "xxxxxx",
            ...
            "status": "approved"
        }
    ],
    "name": "appA",
    "scopes": [],
    "status": "approved"
}
	

@Chris Novak thank you for the answer. I am new to this so I am still confused. How do I access this ? I am using form validate function on button click. Can you tell me where do I use this app detail and how do I change it to approve? Any help will be appreciated.

Are you using our Drupal 7 portal? Check out our info on creating a custom Drupal 7 module. When you create a new app, the devconnect_developer_apps_edit_form_submit() function gets called. You can create a custom module to override the submit function for that form to do whatever you want. Make sure to make your own custom module, because if you don't, you will not be able to upgrade to newer versions.

Thank you for the reply Chris. Yes I am using drupal 7 and I have created a custom module and I am using an overridden submit function. My only concern is, how can I change this credentials->apiproducts->status to approved from pending. I am stuck there. If possible, can you give me a sample code how to update it? My submit handler and custom module everything is working fine. I have tested them with different conditions. I just need a code to change pending to approve.
Thanks.

@Zohaib Masood

Were you able to implement this?We have a similar requirement