Creating Session Tokens

The create_session operation is used to create a user session token, which can be used in single-use URLs for automatic logging in to Plesk. Using session tokens is a recommended, more secure way than passing login and plain password in URL.

For details about the one-time use URL, see Automatic Logging In to Plesk in Advanced Administration Guide for Linux or Advanced Administration Guide for Windows.

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 

Request Packet Structure

A request contains the create_session operation node:

<packet>
  <server>
    <create_session>
      ...
    </create_session>
  </server>
</packet>

 

The create_session node is presented by the complex type CreateSessionType (server_input.xsd) and structured as follows:

create_session

Important: All values for session parameters (from user_ip to back_url) must be encoded using the Base64 algorithm.

If optional parameters are not specified in an XML API request, then Plesk uses default values. Otherwise, the values you set in a request will replace the default ones.

User's email address, phone number and preferred language will be stored in Plesk permanently for the specified user. Other parameters work only during a session.

The following request creates a session for the user admin:

<packet>
  <server>
    <create_session>
      <login>admin</login>
      <data>
        <user_ip>MTAuNTAuMS43MQ==</user_ip>
        <source_server></source_server>
      </data>
    </create_session>
  </server>
</packet>

The login parameter specifies the Plesk user for whom you want to create a session. The user-ip parameter is an IP address of the user, encoded using the Base64 algorithm.

Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.

 

Response Packet Structure

The create_session node of the response packet is structured as follows:

create_session_result

   

 

Samples

This request creates session tokens:

<packet>
  <server>
    <create_session>
      ...
    </create_session>
  </server>
</packet>

Response:

<packet>
  <server>
    <create_session>
      <result>
        <status>ok</status>
        <id>ede520d0fc93ae7aa0524076d631fba2</id>
      </result>
    </create_session>
 </server>
</packet>

Plesk creates a session token for the specified user. It is contained in the id tag (ede520d0fc93ae7aa0524076d631fba2 in the example).