Authentification to Rational Team Concert with Javascript and REST Api
I'm building a Web application to access some informations about project-areas/team-areas | WorkItems | etc... I want to get thoses informations with Javascript and I used the REST Api / OSLC.
I'm facing some troubles with the authentification.
I don't know how can I create and manage the authentification to the server.
I have the username and password but what should I do with that ?
Is there a guide or tutorial to use the REST api with javascript ?
I tried to use curl in a php file but it didn't work (it returned me an empty string maybe because I was not logged at that time ?)...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://<server>/ccm/rpt/repository");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Thanks in advance for your help !
2 answers
Check out this post and see if it helps.
https://jazz.net/forum/questions/170030/rtc-oslc-authenticate-with-javascript
If the JavaScript is running as part of RTC (as a OpenSocial Widget for example), you can check out these posts.
https://jazz.net/forum/questions/215022/access-rtc-with-oslc-using-javascript
https://jazz.net/forum/questions/212195/how-to-create-work-item-using-javascript-within-an-opensocial-gadget
But reading your post, I have the impression that you get confused about what you are doing. If you use Perl, it runs on the server where your own web application runs, there should be no involvement of JavaScript at all. In this case, there are plenty of sample Perl scripts on jazz.net. If you indeed want to use JavaScript on the client side (a browser) of your own web application, it means that it reads data from RTC, then feeds back to the backend (server side) of your application - that's a lot of work to do. I don't know why you would make it so complicated.
There some sample code at https://github.com/OSLC/oslc-client that might be helpful. This uses JEE Form based authentication to connect a JavaScript client to RTC.