Invoke the Login
operation of the /atg/userprofiling/InternalProfileFormHandler
component to log in to the REST Web Services server as an internal user. Supply your username and password as functional parameters with the HTTP POST request. Use the parameter name value.login
for the username and value.password
for the password.
See information about functional parameters and invoking form handler components in Functional Parameters and Invoking Form Handlers .
Include the atg-rest-return-form-handler-exceptions
control parameter when you invoke this form handler. This will cause the server to return exceptions that occur during the log in operation. If you do not include this control parameter, you will not be able to distinguish between a successful attempt to log in and one that fails. See Success and Failure Responses for Internal User Log In.
Success and Failure Responses for Internal User Log In
Make sure you include the atg-rest-return-form-handler-exceptions
control parameter when you invoke /atg/userprofiling/InternalProfileFormHandler/login
. If you do not use this control parameter, you will not be able to distinguish between a successful log in attempt and one that fails. See Control Parameters.
If your attempt to log in is successful, the REST Web Services server will return a response with no exceptions and the HTTP status code 200 OK
. For example:
<atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions/> <result>true</result> </atgResponse>
If your attempt to log in fails, the server will return the exceptions encountered in an HTTP response with status code 200 OK
. For example:
<atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions> <formExceptions> <element>The password is incorrect</element> </formExceptions> </exceptions> <result>true</result> </atgResponse>
Note: the server returns status code 200 OK
in both conditions. Make sure you examine the response value to determine whether an attempt to log in succeeded.
Example of Logging in as an Internal User
The following example shows an HTTP request to open a REST Web Services session as an internal user. The server returns a session identifier in the field labeled JSESSIONID
.
curl -v -c cookies.txt -X POST \ -H "Content-Type: application/json" \ -d "{ value.login=MyInternalUsername , value.password=MyInternalPassword }" \ http://myserver:8280/rest/bean/atg/userprofiling/InternalProfileFormHandler/login?atg-rest-return-form-handler-exceptions=true * About to connect() to myserver port 8280 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8280 (#0) > POST /rest/bean/atg/userprofiling/InternalProfileFormHandler/login?atg-rest-return-form-handler-exceptions=true HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8280 > Accept: */* > Content-Type: application/json > Content-Length: 70 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 * Added cookie JSESSIONID="09FA8F5B4B8A4C1A1E97480A91BA7EB8" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=09FA8F5B4B8A4C1A1E97480A91BA7EB8; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAsU2VhcmNoLzEwLjAg WyBQbGF0Zm9ybUxpY2Vuc2UvMCBT ZWFyY2hBZG1pbkxpY2Vuc 2UvMCBQdWJsaXNoaW5nTGljZW5zZS8wIEIyQ0xpY2Vuc2UvMCAgXQ== < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 28 Oct 2010 20:57:22 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions/> <result>true</result> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0