How to create Autologin using an API request in Plesk?

Refers to:

  • Plesk 12.5 for Linux
  • Plesk 11.0 for Windows
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Windows
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux

Created:

2016-11-16 13:21:06 UTC

Modified:

2016-12-21 20:31:24 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to create Autologin using an API request in Plesk?

Symptoms

How to create Autologin using an API request in Plesk?

Resolution

Create an XML file, in this example it will be named request.xml , with the following content in case if you want to create a session for ' TEST_USER ' user:

<?xml version='1.0'?>
<packet version="1.6.3.5">
<server>
<create_session>
<login>TEST_USER</login>
<data>
<!-- Base64-encoded IP address of client, who logs into Plesk -->
<user_ip>MTkyLjE2OC4zNC4xOTI=</user_ip>
<!-- Base64-encoded hostname of computer from which the request is sent -->
<source_server>d3BiLXNpdGUudGxk</source_server>
</data>
</create_session>
</server>
</packet>

Session token will be created for the user identified by login.

Send created XML file to Plesk using curl :

# curl -kLi -H "Content-Type: text/xml" -H "HTTP_AUTH_LOGIN: admin" -H "HTTP_AUTH_PASSWD: PASSWORD" -H "HTTP_PRETTY_PRINT: TRUE" -d @request.xml https://<server-host-or-ip>:8443/enterprise/control/agent.php

NOTE : Only ' admin ' user is able to create session token for clients/resellers logins.

Response may look like the following:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.3.3">
<server>
<create_session>
<result>
<status>ok</status>
<id>ede520d0fc93ae7aa0524076d631fba2</id>
</result>
</create_session>
</server>
</packet>

Value of id tag will contain session token ' ede520d0fc93ae7aa0524076d631fba2 '.

Now, script can redirect user’s browser to rsession_init.php and user will be logged in to Control Panel.

URL for Linux version of product:

https://<server-host-or-ip>:8443/enterprise/rsession_init.php?PHPSESSID=ede520d0fc93ae7aa0524076d631fba2&success_redirect_url=<success_redirect_url>

For Windows version add PLESKSESSID the same as PHPSESSID to URL.

https://<server-host-or-ip>:8443/enterprise/rsession_init.php?PHPSESSID=ede520d0fc93ae7aa0524076d631fba2&PLESKSESSID=ede520d0fc93ae7aa0524076d631fba2`

Here is the list of options:

  • PHPSESSID (Linux only) - session token.
  • PLESKSESSID (Windows only) - session token.
  • success_redirect_url (optional) - URL where browser will be redirected after successful login procedure.
  • failure_redirect_url (optional) - URL where browser will be redirected after failure login attempt. Also this parameter will be used as logout URL.
  • no_frames (optional, deprecated) - show admin panel without frames
  • locale_id (optional) - locale name (e.g. de-DE)

Additional information is available in XML API Guide

Have more questions? Submit a request
Please sign in to leave a comment.