Search code examples
phpusergrid

How do you assign a role to a new user on signup in UserGrid using php?


I am trying to develop a POC using UserGrid where a user can signup and then login and then can simply upload images to store online and download it later. Somewhat similar to a OneDrive.

I am using the api.usergrid.com

Using the dashboard I have created some Roles(admin, default, guest, etc) and assigned them Permissions.

So whenever I signup a new user how can assign that user a role using php?

I am using this as a reference: https://github.com/apache/usergrid/tree/master/sdks/php


Solution

  • There doesn't appear to be a specific SDK method for this right now. But when you create the user, you can use post the connection directly with $client->post($endpoint, $query_string_array, $body) where the endpoint is roles//users/

    Request is described here: http://usergrid.apache.org/docs/security-and-auth/using-roles.html

    There's a connection method in the SDK, but it requires a connection type, which is a different syntax for this type of role connection.