public static NPMResponse GetLoginToken(string url, string user, string password)
        {
            using (var client = new WebClient())
            {
                string loginUri = UrlCombine(url, "/-/user/org.couchdb.user:"******"application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add(HttpRequestHeader.Authorization, "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + password)));

                NPMLoginRequest request = new NPMLoginRequest();
                request.name     = user;
                request.password = password;

                string requestString = JsonUtility.ToJson(request);

                try
                {
                    string      responseString = client.UploadString(loginUri, WebRequestMethods.Http.Put, requestString);
                    NPMResponse response       = JsonUtility.FromJson <NPMResponse>(responseString);
                    return(response);
                }
                catch (WebException e)
                {
                    NPMResponse response = new NPMResponse();
                    response.error = WebExceptionParser.ParseWebException(e);
                    return(response);
                }
            }
        }
        public static NPMResponse GetLoginToken(string url, string user, string password)
        {
            using (var client = new WebClient())
            {
                string loginUri = UrlCombine(url, "/-/user/org.couchdb.user:"******"application/json");
                client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
                client.Headers.Add(HttpRequestHeader.Authorization, "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + password)));

                NPMLoginRequest request = new NPMLoginRequest();
                request.name     = user;
                request.password = password;

                string requestString = JsonUtility.ToJson(request);

                try
                {
                    string      responseString = client.UploadString(loginUri, WebRequestMethods.Http.Put, requestString);
                    NPMResponse response       = JsonUtility.FromJson <NPMResponse>(responseString);
                    return(response);
                }
                catch (WebException e)
                {
                    if (e.Response != null)
                    {
                        try
                        {
                            Stream receiveStream = e.Response.GetResponseStream();
                            // Pipes the stream to a higher level stream reader with the required encoding format.
                            StreamReader readStream     = new StreamReader(receiveStream, Encoding.UTF8);
                            string       responseString = readStream.ReadToEnd();
                            e.Response.Close();
                            readStream.Close();

                            return(JsonUtility.FromJson <NPMResponse>(responseString));
                        }
                        catch (Exception e2)
                        {
                            NPMResponse response = new NPMResponse();
                            response.error = e2.Message;
                            return(response);
                        }
                    }
                    else
                    {
                        NPMResponse response = new NPMResponse();
                        response.error = e.Message;
                        return(response);
                    }
                }
            }
        }