diff --git a/src/base-apis.js b/src/base-apis.js index 472e45f51..1bdfb1f7e 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -246,16 +246,30 @@ MatrixBaseApis.prototype.register = function( /** * Register a guest account. + * This method returns the auth info needed to create a new authenticated client, + * Remember to call `setGuest(true)` on the (guest-)authenticated client, e.g: + * ```javascript + * const tmpClient = await sdk.createClient(MATRIX_INSTANCE); + * const { user_id, device_id, access_token } = tmpClient.registerGuest(); + * const client = createClient({ + * baseUrl: MATRIX_INSTANCE, + * accessToken: access_token, + * userId: user_id, + * deviceId: device_id, + * }) + * client.setGuest(true); + * ``` + * * @param {Object=} opts Registration options * @param {Object} opts.body JSON HTTP body to provide. * @param {module:client.callback} callback Optional. - * @return {Promise} Resolves: TODO + * @return {Promise} Resolves: JSON object that contains: + * { user_id, device_id, access_token, home_server } * @return {module:http-api.MatrixError} Rejects: with an error response. */ MatrixBaseApis.prototype.registerGuest = function(opts, callback) { opts = opts || {}; opts.body = opts.body || {}; - this.setGuest(true); return this.registerRequest(opts.body, "guest", callback); };