Difference between revisions of "XML-RPC Protocol Method: login"

From Dreamwidth Notes
Jump to: navigation, search
(Added Update template to indicate need for verification against DW code.)
 
Line 164: Line 164:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
[[Category: Development]]
+
[[Category: XML-RPC Protocol]]

Latest revision as of 03:06, 23 September 2010

Needs Update: This documentation was ported over from LJ's Server Manual with minimal modification. It may not match Dreamwidth's implementation of the method, and needs to be double checked against the DW code and updated as necessary.

Login to the server, while announcing your client version. The server returns with whether the password is good or not, the user's name, an optional message to be displayed to the user, the list of the user's friend groups, and other things.

Inputs

username Scalar. Required. Username of user logging in.

auth_method Scalar. Optional. Authentication method used for this request. The default value is "clear", for plain-text authentication. "cookie" and any of the challenge-response methods are also acceptable.

password Deprecated. Scalar. Optional. Password of user logging in in plaintext. If using the "clear" authentication method, either this or "hpassword" must be present.

hpassword Deprecated. Scalar. Optional. MD5 digest of user's password. Not much more secure than password, but at least it's not in plain text.

auth_challenge Scalar. Optional. If using challenge-response authentication, this should be the challenge that was issued to you by the server.

auth_response Scalar. Optional. If using challenge-response authentication, this should be the response hash that you generate, based on the formula required for your challenge.

ver Scalar. Optional. Protocol version supported by the client; assumed to be 0 if not specified. See Protocol Versions for details on the protocol version.

clientversion Scalar. Optional. Although optional, this should be a string of the form Platform-ProductName/ClientVersionMajor.Minor.Rev, like Win32-MFC/1.2.7 or GTK2-LogJam: 4.5.3. Note in this case that "GTK2" is not a platform, but rather a toolkit, since the toolkit is multi-platform (Linux, FreeBSD, Solaris, Windows...). You make a judgment what is best to send, but if it is of this form, we give you cool statistics about your users.

getmoods Scalar. Optional. If your client supports moods, send this key with a value of the highest mood ID you have cached/stored on the user's computer. For example, if you logged in last time with and got mood IDs 1, 2, 4, and 5, then send "5" as the value of "getmoods". The server will return every new mood that has an internal MoodID greater than 5. If you've never downloaded moods before, send "0". If you don't care about getting any moods at all (if your client doesn't support them), then don't send this key at all.

getmenus Scalar. Optional. Send something for this key if you want to get a list/tree of web jump menus to show in your client.

getpickws Scalar. Optional. If your client supports picture keywords and you want to receive that list, send something for this key, like "1", and you'll receive the list of picture keywords the user has defined.

getpickwurls Scalar. Optional. If your client supports picture keywords and can also display the pictures somehow, send something for this key, like "1", and you'll receive the list of picture keyword URLs that correspond to the picture keywords as well as the URL for the default picture. You must send getpickws for this option to even matter.

Example Request

POST /interface/xmlrpc HTTP/1.0
User-Agent: XMLRPC Client 1.0
Host: www.dreamwidth.org
Content-Type: text/xml
Content-Length: 396
 
<?xml version="1.0"?>
<methodCall>
  <methodName>LJ.XMLRPC.login</methodName>
  <params>
    <param>
      <value><struct>
        <member>
          <name>username</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>password</name>
          <value><string>test</string></value>
        </member>
        <member>
          <name>ver</name>
          <value><int>1</int></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodCall>

Outputs

fullname Scalar. Required. The user's full name. Often, clients use this to change the top-level window's title bar text to say something like "Dreamwidth - User name". You can just ignore this if you'd like.

message Scalar. Optional. A message that should be displayed in a dialog box (or to the screen in a console application). The message is rarely present but when used notifies the user of software updates they've requested to hear about, problems with their account (if mail is bouncing to them, we'd like them to give us a current e-mail address), etc. For example, on Dreamwidth.org a newly-created account will return a message telling the user the e-mail address used for their account has not yet been validated.

friendgroups Array of structs. Required. List of the user's trustgroups. Each struct in this array contains these keys:

  • id Scalar. Required. The bit number for this trust group, from 1-30.
  • name Scalar. Required. The name of this trust group.
  • sortorder Scalar. Required. The sort integer for this trust group, from 0-255.
  • public Scalar. Required. Either '0' or '1' for if this trust group is public.

usejournals Array of scalars. Optional. List of shared/news/community journals that the user has permission to post in. Each array item holds the username of community journal.

moods Array of structs. Optional. If you sent the getmoods key in your request, this is returned. The contents are the new moods that have been added on the server since you last requested the list. Your client should cache the mood list on the client's computer to avoid requesting the whole list every time. Containing keys:

  • id Scalar. Required. The integer moodid.
  • name Scalar. Required. The mood name.
  • parent Scalar. Required. The mood's parent (base) moodid.

pickws Array of scalars. Optional. This is returned if you set getpickws in your request. Picture keywords are used to identify which userpic (100x100 icon) to use for that particular post. For instance, the user may have "Angry", "Happy", and "Sleepy" picture keywords which map to certain pictures. The client should also do a case-insensitive compare on this list when a mood is selected or entered, and auto-select the current picture keyword. That way it seems that selecting a mood also sets their corresponding picture. Each array item contains the picture keyword.

pickwurls Array of scalars. Optional. The URLs of the user pictures. They correspond with the list of picture keywords returned. Note that the content behind these URLs can never change, so if your client downloads these to display, just cache them locally and never hit the servers again to re-download them or to even check if they've been modified. Each array item contains the picture URL.

defaultpicurl Scalar. Optional. The URL of the default picture (if you sent the getpickwurls key). Note that the content behind this URL can never change, so you can cache it locally; also note that the default picture might have no keyword associated with it.

fastserver Scalar. Optional. Dreamwidth sites may have priority servers for paying customers. If this key is both present and set to value "1", then the client has permission to set the "ljfastserver" cookie in subsequent requests. The HTTP request header to send is "Cookie: ljfastserver=1". If you send this header without getting permission from the login mode, your requests will fail. That is, you'll trick the load balancer into directing your request towards the priority servers, but the server you end up hitting won't be happy that you're trying to scam faster access and will deny your request.

userid Scalar. Required. The userid of this user on the system. Not required for any other requests to the server, but some developers have wanted it.

menus Array of structs. Optional. Returned if you set getmenus in your request. List of menu items in order that should be in the Dreamwidth web menu in the client application. Each struct in the array contains these keys:

  • text Scalar. Required. The text of the menu item, or "-" for a separator.
  • url Scalar. Optional. The URL the menu item should launch, present for all menu items except separators and submenus.
  • sub Array of structs. Optional. If this is present, this menu item is a submenu. Each struct in the array has the same format as top-level menu structure.

Example Response

HTTP/1.1 200 OK
Connection: close
Content-length: 755
Content-Type: text/xml
Date: Sun, 14 Jul 2002 23:45:59 GMT
Server: Apache/1.3.4 (Unix)
 
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value><struct>
        <member>
          <name>userid</name>
          <value><int>3</int></value>
        </member>
        <member>
          <name>message</name>
          <value><string>You need to validate your new email address.  
Your old one was good, but since you've changed it, you need to re-validate the new one.  
Visit the support area for more information.</string></value>
        </member>
        <member>
          <name>fullname</name>
          <value><string>Test Account</string></value>
        </member>
        <member>
          <name>friendgroups</name>
          <value><array><data>
          <data/></array></value>
        </member>
        <member>
          <name>usejournals</name>
          <value><array><data>
            <value><string>test2</string></value>
          </data></array></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodResponse>