Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using Crowd to authenticate my app

Kevin Metts August 4, 2013

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.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Graham Bakay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2013

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.

0 votes
Kevin Metts August 5, 2013

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.

TAGS
AUG Leaders

Atlassian Community Events