createMagicURLSession method

Future<Token> createMagicURLSession({
  1. required String userId,
  2. required String email,
  3. String? url,
})

Create Magic URL session

Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the PUT /account/sessions/magic-url endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.

A user is limited to 10 active sessions at a time by default. Learn more about session limits.

Implementation

Future<models.Token> createMagicURLSession(
    {required String userId, required String email, String? url}) async {
  const String path = '/account/sessions/magic-url';

  final Map<String, dynamic> params = {
    'userId': userId,
    'email': email,
    'url': url,
  };

  final Map<String, String> headers = {
    'content-type': 'application/json',
  };

  final res = await client.call(HttpMethod.post,
      path: path, params: params, headers: headers);

  return models.Token.fromMap(res.data);
}