'permission_obj' param should be a string. 
                e.g. '[{"access":"d_u_list","oid":{"id":"1576946496","type":"Domain"}}]'

        http://docs.exosite.com/portals/#add-user-permission

def create_token(self, user_id, permission_obj):
        """ 'permission_obj' param should be a string. 
                e.g. '[{"access":"d_u_list","oid":{"id":"1576946496","type":"Domain"}}]'

        http://docs.exosite.com/portals/#add-user-permission
        """

        headers = {
                'User-Agent': self.user_agent(),
                'Content-Type': self.content_type()
        }
        headers.update(self.headers())

        url = self.portals_url()+'/users/{0}/permissions'.format(user_id)
        # print("URL: {0}".format(url))
        r = requests.post(  url,
                            data=permission_obj,
                            headers=headers,
                            auth=self.auth())
    
        if HTTP_STATUS.OK == r.status_code:
            return r.json()
        else:
            print("create_token: Something went wrong: <{0}>: {1}".format(
                        r.status_code, r.reason))
            r.raise_for_status()