Beispiel #1
0
        /// <summary>
        /// Create a new user account.
        /// </summary>
        /// <exception cref="FirebaseException">If an error occurs while creating the user account.</exception>
        /// <param name="args">The data to create the user account with.</param>
        /// <param name="cancellationToken">A cancellation token to monitor the asynchronous
        /// operation.</param>
        /// <returns>The unique uid assigned to the newly created user account.</returns>
        internal async Task <string> CreateUserAsync(
            UserRecordArgs args, CancellationToken cancellationToken = default(CancellationToken))
        {
            var payload  = args.ThrowIfNull(nameof(args)).ToCreateUserRequest();
            var response = await this.PostAndDeserializeAsync <JObject>(
                "accounts", payload, cancellationToken).ConfigureAwait(false);

            var uid = response["localId"];

            if (uid == null)
            {
                throw new FirebaseException("Failed to create new user.");
            }

            return(uid.Value <string>());
        }