Hey Guys, I have been tasked with using Crowd to allow users to login to an app that I created. I have been attempting this using the REST API.
I started by adding the application on the Crowd Applications tab. I can currently run the curl command and everthing seems to work correctly but it is not working from the login page that I created. I am using Jquery to post the data on form submission and that function is
<script>
$(function(){
$("#authenticate").on("click", function(){
authenticate();
});
});
function authenticate(){
var user = document.getElementById("loginField").value;
var password = document.getElementById("passwordField").value;
var data = '{ "value": "'+password+'" }';
var url = "https://MYDOMAIN/crowd/rest/usermanagement/1/authentication?username="+user;
$.ajax({
type: "POST",
url: url,
data: data,
async: false,
success: alert (user),
}).done(function(data) {
console.log(data);
});
}
</script>
When the form is submitted I get the 401 Unauthorized message in the console. I am wondering if I am going about this the correct way. Maybe a better question is what is the best way to login to a custom built app using Crowd? Any suggestions? Thanks for your time.
Community moderators have prevented the ability to post new answers.
You're missing a step. You indeed need to authenticate your app to Crowd before you can go about asking Crowd about anything (like authenticating a user). That's why you're getting a 401 error.
First, you need to have your app configured in Crowd.
Then, you'll need to authenticate your app using HTTP Basic Auth on every request, or (possibly preferably) hang onto the cookie that Crowd will give you after you authenticate your app correctly. There's lots on Stack Exchange on how to either set a header to do HTTP Basic Auth, or use username/password params on your jQuery HTTP call.
Essentially, if you include username/password params which have your application's name and password in the jQuery HTTP call, and your app and IP range is set up in Crowd correctly, you should be able to hit the REST resources and not get a 401 response.
Hope this helps you along.
Graham.
I believe that maybe the issue is with the apps username and password that is set up in Crowd. I am not totally sure how that should be passed in the Web form. With that being said, maybe the login page is not getting access to the app via that login and password. I tried appending it to the front of the URL as like app_username:app_password@MYDOMAIN but that did not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.