Automatically create an app for a new user after registration

Not applicable

We're finding that users are having difficultly with the registration flow in our portal. Once they have registered as users and validated their email address, they often need help to figure out that the next step is to create a new app to get an API key.

In our case, this step is unncessary, we only offer one API product. It would be simpller to skip this intervening step and give all new users an app and API key as soon as they register. Is it possible to configure the developer portal to do that?

1 6 297
6 REPLIES 6

I think you want to start with hook_user_insert. Apigee uses it to generate an email:

devconnect_admin_notify.module

/**
 * Implements hook_user_insert().
 */
function devconnect_admin_notify_user_insert(&$edit, &$account, $category = NULL) {
  if ($account->status) {
    devconnect_admin_notify_setup_email($edit, $account);
  }

From there maybe look through their ManagementAPI collection of classes (/profiles/apigee/libraries/mgmt-api-php-sdk/Apigee/ManagementAPI) to see what might be possible to use to create the app.

@tpearson ,

It's very common use case we saw across customers, Recent releases of developer portal made it so easy and you can achieve same using Rules module without writing any code.

1405-screen-shot-2015-10-29-at-94442-am.png

Thanks @Anil Sagar . I can't get this working correctly though, when I create the new user I get the message

1855-rules-error.png

My parameters are

Parameter: 
	App Display Name: [developer:userName] first app, 
	App Internal Name: [developer:uid], 
	Developer UID: [developer:uid], 
	Status: approved, 
	App Description: [developer:email], 
	API Products: amadeus_sandbox


but even a very simple parameters you provided, it doesn't work.

In the logs, I see the message

 Type	access denied 
 User	Anonymous (not verified) 
 Location	https://dev-amadeus-sandbox.devportal.apigee.com/user/1946/edit 
 Message	user/1946/edit 
 Severity	warning

My guess is that Drupal is not allowing the operation because the user has not yet logged in and set their password, but I can't see anyway to make this operation occur after first login. Any ideas?

Hmm - I tried adding this to the first login action by setting the rule to occur on event User has logged in with the condition

Data value is empty
site:current-user:last-access

Now the access denied message goes away, but I can no longer access the variable [developer:uid] which is required to create the application for the developer. This results in the following error from Edge in the logs

{
  "code" : "developer.service.DeveloperIdDoesNotExist",
  "message" : "DeveloperId apps does not exist in organization amadeus-sandbox",
  "contexts" : [ ]
}

Do you have any suggestions on how to make this work?

@Apigee SOS - any chance I can get some help on this one?

OK, I found a workaround that will take me half-way there. When the user saves their profile, we'll take them to the MyApps page where they can create the app.

This works with the following rule

Event: After updating an existing user account

Actions: Page Redirect

    Parameter: URL: /user/me/apps

Hope that helps!