javascriptangularjskinveymbaas

Autogenerate User with Kinvey


Using Kinvey is there a way to autogenerate users (like in this document: http://devcenter.kinvey.com/ios/guides/users#autogenerated) but for REST or AngularJS?


Solution

  • Autogenerate users is basically a signup with email, which ends up creating a random username and password.

    It is possible to do with any of Kinvey SDKs as well as with REST:

    1. AngularJS

      var promise = $kinvey.User.signup({
        email : '<user-email>'
      });
      promise.then(function(user) {
        alert('Kinvey User signup Success.');
      }, function(err) {
        alert('Kinvey User signup Failed.');
      });
      
    2. REST

    POST /user/:appKey/ HTTP/1.1
    Host: baas.kinvey.com
    Authorization: [Basic Auth with app credentials]
    Content-Type: application/json
    {"email" : "<user-email>"}
    

    The user email is optional if you don't enforce Email verification in user settings of your Kinvey app.

    In that case, you can do a POST request with an empty body i.e. {}.

    References:

    1. http://devcenter.kinvey.com/angular/guides/users#signup
    2. http://devcenter.kinvey.com/rest/guides/users#signup