Skip to content

Commit accfa32

Browse files
authored
Merge pull request #1641 from NicolaiSoeborg/fix-registerGuest
docs: registerGuest()
2 parents c1144e3 + 2d4a4f1 commit accfa32

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/base-apis.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,25 @@ MatrixBaseApis.prototype.register = function(
246246

247247
/**
248248
* Register a guest account.
249+
* This method returns the auth info needed to create a new authenticated client,
250+
* Remember to call `setGuest(true)` on the (guest-)authenticated client, e.g:
251+
* ```javascript
252+
* const tmpClient = await sdk.createClient(MATRIX_INSTANCE);
253+
* const { user_id, device_id, access_token } = tmpClient.registerGuest();
254+
* const client = createClient({
255+
* baseUrl: MATRIX_INSTANCE,
256+
* accessToken: access_token,
257+
* userId: user_id,
258+
* deviceId: device_id,
259+
* })
260+
* client.setGuest(true);
261+
* ```
262+
*
249263
* @param {Object=} opts Registration options
250264
* @param {Object} opts.body JSON HTTP body to provide.
251265
* @param {module:client.callback} callback Optional.
252-
* @return {Promise} Resolves: TODO
266+
* @return {Promise} Resolves: JSON object that contains:
267+
* { user_id, device_id, access_token, home_server }
253268
* @return {module:http-api.MatrixError} Rejects: with an error response.
254269
*/
255270
MatrixBaseApis.prototype.registerGuest = function(opts, callback) {

0 commit comments

Comments
 (0)