To Install cURL in your Ubuntu System, run the following command in your terminal:
- sudo sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
- sudo apt-get update
- sudo apt-get install curl
Now its time to run some cURL command to login
- curl -i -H "Content-type: application/x-www-form-urlencoded" -c cookies.txt -X POST http://localhost:8080/myGrailsApp/j_spring_security_check -d "[email protected]&j_password=oodles"
- If you get successfully logged in response will be
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=F7A7D768C65E601A44649C2BECC6B879; Path=/; HttpOnly
Location: http://localhost:8080/myGrailsApp
Content-Length: 0
Date: Wed, 29 Jan 2014 10:51:41 GMT - If your authentication fails then response will be
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Set-Cookie: Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: JSESSIONID=D143DFD97A0E0C0155F8DB3F7E50065D; Path=/; HttpOnly
Location: http://localhost:8080/myGrailsApp/login/authfail?login_error=1
Content-Length: 0
Date: Wed, 29 Jan 2014 11:05:20 GMT
After this we can call all the Spring security secured controllers and actions like this-
- curl -i -b cookies.txt -X GET http://localhost:8080/myGrailsApp/controllerName/actionName
More From Oodles
Ready to innovate? Let's get in touch
Request for Proposal
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ashish Sharma
Ashish is a bright Groovy and Grails developer and have worked on development of various SaaS applications using Grails technologies. Ashish likes PC games and works out at Gym in his free time.