gs.auth.token
Documentation¶
Author: | Michael JasonSmith |
---|---|
Contact: | Michael JasonSmith <mpj17@onlinegroups.net> |
Date: | 2015-06-18 |
Organization: | GroupServer.org |
Copyright: | This document is licensed under a Creative Commons Attribution-Share Alike 4.0 International License by OnlineGroups.net. |
This product provides an API to allow people to be added to a GroupServer group, without an invitation being sent [1]. There are two slight variants:
- One is a web hook, designed to be used by external systems.
- The other requires a cookie for authentication, and is designed to be used by the JavaScript on GroupServer pages
Contents:
Web hook¶
Synopsis¶
/gs-group-member-add.json
? token
=<t> & groupId
=<g> & email
=<e> & fn
=<n> [& biography
=<b>] [& tz
=<t>] & add
Description¶
The web hook gs-group-member-add.json
, in the site context,
adds a person to a group on the site.
- If the person is new to the system then a profile is created and the person is added to the group.
- If the person already has a profile then they are just added to the group.
- Otherwise an error is raised (see Returns).
Required arguments¶
-
groupId
=<groupId>
¶ The identifier for the group that the person is joining.
-
email
=<address>
¶ The email address of the new group member. The email address is used as the identifier for the person (see Returns):
- If the email has never been seen by the system then a new profile is created,
- Otherwise an existing profile is added to the group.
-
fn
=<name>
¶ The name of the new member.
-
add
¶
The action (no value needs to be set, but the argument must be present).
Optional arguments¶
-
biography
=<bio>
¶ The HTML-formatted biography for the new member.
-
tz
=<tz>:
¶ The timezone for the new member.
Note: | Unlike the cookie version (see Cookie), the web hook can only handle the basic GroupServer profile information. This is because the hook is in the context of the site rather than the context of a group (because the hook is visible to the public, but the group may be secret) and groups can have specific settings. |
---|
Returns¶
On completion a JSON object is returned. In the returned object
the status
and message
fields are always
set, with the user
field usually set.
-
class
Returns
()¶ -
status
¶ 0
: success, as a profile was created and the person was added to the group.1
: success, as a person with an existing profile was added to the group.256
: failure, as the person was already a group member.257
: unexpected failure.
-
message
¶ A message explaining the status.
-
user
¶ In the case that a new member was added to the group, or the person was already a member of the group (the statuses
0
,1
, and256
) then theuser
property will be set with the standard user-property values set (see the core web-hook documentation).
-
Example¶
Add a person with the name A Person
and the email
a.person@home.example.com
to the test
group on
groups.example.com
using wget.
$ wget http://groups.example.com/gs-group-member-add.json \
--post-data='token=Fake&groupId=test&email=a.person@home.example.com@fn=A%20Person&add'
[1] | See gs.auth.token for more information
<https://github.com/groupserver/gs.auth.token> |
Cookie¶
The impetus for creating this end-point is to provide an
mechanism for the JavaScript based bulk adding [1]. To see
a list of available parameters, including which parameters are
required, make a GET
request to gs-group-member-add.json
in the Group context.
To add, make a POST
request to gs-group-member-add.json
,
supplying all required data via the
application/x-www-form-urlencoded content-type. This
request must include the parameter submit
to indicate the
request is to be processed [2]. This request must also
pass a cookie with the parameter __ac and a value that
corresponds to an authenticated session.
fromAddr
¶
The documentation provided by gs-group-member-add.json
indicates that fromAddr
is required, but does not indicate
that only certain values are accepted: fromAddr
must be an
email address associated with the authenticated session the
submitted cookie corresponds to.
CURL Example¶
Assuming an instance of GroupServer is running at gsbox
, the
following example will attempt to add a user to the Example
Group:
$ curl -H "Accept: application/json" -b "__ac=<VALUE_FROM_BROWSER>" \
-X POST -d "toAddr=example_user%40example.com&fn=Example%20User&delivery=email&message=Hi&fromAddr=<YOUR_EMAIL_ADDRESS>&subject=Welcome&submit" \
http://gsbox/groups/example_group/gs-group-member-add.json
In Firefox, if you are logged into your GroupServer instance, you
can find the value for __ac
at
<chrome://browser/content/preferences/cookies.xul>.
[1] | The code for adding people in bulk is provided by
gs.group.member.add.csv
<https://github.com/groupserver/gs.group.member.add.csv> |
[2] | Blame zope.formlib for requiring the submit
parameter. Or just blame HTTP and HTML for being generally
messed up when it comes to forms. |
Changelog¶
1.1.0 (2014-01-28)¶
- Sanitising the addresses before returning them
- Updating the product metadata
1.0.0 (2014-01-10)¶
Initial version, forked off gs.group.member.add.base and using the same API as gs.group.member.invite.json. Prior to the creation of this product people could only be added to groups using HTML forms.
Indices and tables¶
Resources¶
- Code repository: https://github.com/groupserver/gs.group.member.add.json
- Questions and comments to http://groupserver.org/groups/development
- Report bugs at https://redmine.iopen.net/projects/groupserver
[1] | The equivalent for inviting people is provided
by gs.group.member.add.json
<https://github.com/groupserver/gs.group.member.add.json> |