gdocs:authenticate

Purpose

Authenticates the user with Google Docs™.

There are two mutually exclusive methods of authenticating with Google Docs. The first method requires an email address and the user's password. The second method is based on the Google AuthSub mechanism and requires a token. Refer to Authentication for Installed Applications and AuthSub Authentication for Web Applications for further information.

Contained by

Attributes

Attribute Description Type Default Options Use
captcha-key The key supplied by Google Docs as a part of a CAPTCHA challenge. The value of this attribute can be retrieved from the response using the pipeline:errorInfo function. xs:string     optional 
captcha-value The value provided by the user in response to the CAPTCHA challenge. xs:string     optional 
password The user's password. This attribute is mutually exclusive with token. xs:string     optional 
token The token provided by the Google AuthSub service. This can either be a single use or a session token. The token attribute is mutually exclusive with the user-id and password attributes. xs:string     optional 
user-id The user's email address, for example: foo@gmail.com. This attribute is mutually exclusive with token. xs:string     optional 

Examples

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:gdocs="http://www.volantis.com/xmlns/2008/08/gdocs">
  <head>
    <title>gdocs:list-docs</title>
  </head>
  <body>
    <div>
      <pipeline:transform href="list2xdime.xsl">
        <gdocs:list-docs xml:id="first-list" category="document" query="">
          <gdocs:authenticate user-id="antennatests@gmail.com" password="1antenna1"/>
        </gdocs:list-docs>
      </pipeline:transform>
    </div>
  </body>
</html>

The Google Docs service returns the list of available documents in the form of a feed. You must use an XSL transform to convert the feed to XDIME. The transformation may have the following form.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom"
  version="2.0">
  <xsl:template match="atom:feed">
    <h1>
      <xsl:value-of select="atom:title"/>
    </h1>
    <xsl:for-each select="atom:entry">
      <div>
        <a>
          <xsl:attribute name="href">
            <xsl:value-of select="atom:content/@src"/>
          </xsl:attribute>
          <xsl:value-of select="atom:title"/>
        </a>
      </div>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

The following example illustrates the use of the token-based authentication method.

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:gdocs="http://www.volantis.com/xmlns/2008/08/gdocs">
  <head>
    <title>gdocs:authenticate</title>
  </head>
  <body>
    <div>
      <pipeline:try>
        <pipeline:preferred>
          <pipeline:transform href="list2xdime.xsl">
            <gdocs:list-docs xml:id="fifth list" category="document" page-size="2"
              page-index="2" query="abc">
              <gdocs:authenticate
                token="DQAAAIQAAAAbHygsjmlpSVgXu026biBSM8soeKXASIiPts-lgl_-uAXta4N
                HmgVV2mGEBzZeDQBkp2ecOuW3grmop6hiCnd1mwBYz2IWq5ROD8Znt9kP7E
                kWm3vbjNM1uYm2ICfYfXxopZCbE4PyFJ_CN3W7JrBiYPPG_nSi_ImKxzB6zJj8Du
                mG4sQvVVsymaY6O-LGOVs"/>
            </gdocs:list-docs>
          </pipeline:transform>
        </pipeline:preferred>
        <pipeline:alternative>
          <pipeline:content>
            <p>There was a problem retrieving the information requested.</p>
          </pipeline:content>
        </pipeline:alternative>
      </pipeline:try>
    </div>
  </body>
</html>

Related topics