Beispiel #1
0
        public static string[] Register_User()
        {
            string[] lConnectionDetails = Get_Client_Authentication_Details();


            string[] lResponse = new string[] { null, null };
            string   lPassword = RandPassClass.Generate(8);
            string   lJsonData = "{";

            lJsonData += "\"client_id \": \"" + ConfigurationManager.AppSettings["auth0:ClientId"].ToString() + "\",";
            lJsonData += "\"response_type \": \"code\",";
            lJsonData += "\"redirect_uri \": \"http://localhost:56073/LoginCallback.ashx\",";
            lJsonData += "\"verify_email\": false";
            lJsonData += "\"connection\": facebook";
            lJsonData += "}";


            RestClient lRestClient = new RestClient("https://" + ConfigurationManager.AppSettings["auth0:Domain"].ToString() + "/authorize");


            RestRequest lRestRequest = new RestRequest(Method.GET);

            lRestRequest.AddHeader("authorization", lConnectionDetails[0] + " " + lConnectionDetails[1]);
            lRestRequest.AddParameter("application/json", lJsonData, ParameterType.RequestBody);
            IRestResponse lRestResponse = lRestClient.Execute(lRestRequest);

            return(lResponse);
        }
Beispiel #2
0
        public static string[] Update_User(string pEmailAddress)
        {
            string[] lConnectionDetails = Get_Client_Authentication_Details();


            string[] lResponse = new string[] { null, null };
            string   lPassword = RandPassClass.Generate(8);
            string   lJsonData = "{";

            lJsonData += "\"username\": \"" + pEmailAddress + "\",";
            lJsonData += "\"email\": \"" + pEmailAddress + "\",";
            lJsonData += "\"password\": \"" + lPassword + "\",";
            lJsonData += "\"connection\": \"Username-Password-Authentication\",";
            lJsonData += "\"email_verified\": false,";
            lJsonData += "\"verify_email\": false";
            lJsonData += "}";


            RestClient lRestClient = new RestClient("https://" + ConfigurationManager.AppSettings["auth0:Domain"].ToString() + "/api/v2/users/");


            RestRequest lRestRequest = new RestRequest(Method.POST);

            lRestRequest.AddHeader("authorization", lConnectionDetails[0] + " " + lConnectionDetails[1]);
            lRestRequest.AddParameter("application/json", lJsonData, ParameterType.RequestBody);
            IRestResponse lRestResponse = lRestClient.Execute(lRestRequest);
            JObject       lJObject      = JObject.Parse(lRestResponse.Content);

            if (lJObject["message"] != null)
            {
                lResponse[0] = lJObject["message"].ToString();
            }
            else
            {
                lResponse[1] = lJObject["user_id"].ToString();
            }
            return(lResponse);
        }