Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Google ClientLogin implementation for Node.js. Authenticate into Google services.

Google's ClientLogin authentication implementation for Node.js

Google Client Login officially deprecated

ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible. turned down on April 20, 2015.

Requires at least nodejs 0.4.1



That is an object, filled with the possible error messages.


An object, where you can set the type of account to request authorization for. properties are: google, hosted, hostedOrGoogle default is hostedOrGoogle



emitted when login was success


emitted when an error occured. Has two parameters, the response object and the received data

You can access to their names via constants: or or you can use 'login' and 'error' as string.



Starts the login process. It has one optional parameter, which should be an object with two properties:

logincaptcha, logintoken.

The logincaptcha is the user's answer to the captcha question

You will receive the logintoken if the login failed and the CaptchaRequired error code arrived

You must pass both the logincaptcha and logintoken if you must pass a captcha challange


Returns the value of the authId key from the response. If the login was success you will need to use this value to perform additional requests. You must put it into a the Authorization header like this: 'Authorization': 'GoogleLogin auth=' + googleAuth.getAuthId(),


Returns the value of SID key from the response.


Returns the value of LSID key from the response.


If the login was not success and the user need to pass a captcha challenge this method will return true


Url of the captcha image


You will need to pass it back to the google with the user's answer to the captcha if the login failed and captcha authentication required.


If the login was not success, google will send back an error code what you can get with this method

After the login was success, you should use the AuthId in each of your requests, see example below

list of services:

Name name in googleclientlogin module value
Google Adwords APIs adwords 'adwords'
Google Analytics Data APIs analytics 'analytics'
Google Apps APIs (Domain Information & Management) apps 'apps'
Google Base Data API base 'gbase'
Google Sites Data API sites 'jotspot'
Blogger Data API blogger 'blogger'
Book Search Data API book 'print'
Calendar Data API calendar 'cl'
Google Code Search Data API codesearch 'codesearch'
Contacts Data API contacts 'cp'
Documents List Data API docs 'writely'
Finance Data API finance 'finance'
Gmail Atom feed mail 'mail'
Health Data API health 'health'
Health Data API H9 Sandbox weaver 'weaver'
Maps Data APIs maps 'local'
Picasa Web Albums Data API picasaweb 'lh2'
Sidewiki Data API sidewiki 'annotateweb'
Spreadsheets Data API spreadsheets 'wise'
Webmaster Tools API webmastertools 'sitemaps'
YouTube Data API youtube 'youtube'
C2DM Push Notification Service c2dm 'ac2dm'
Google Reader Data API (unofficial) reader 'reader'
Google Voice API (unoffical) voice 'grandcentral'
Google Music API (unoffical) sj 'sj'

How to use:

var GoogleClientLogin = import('googleclientlogin').GoogleClientLogin;
var googleAuth = new GoogleClientLogin({
  email: '',
  password: 'yourpassword',
  service: 'contacts',
googleAuth.on(, function(){
  // do things with google services
    host: '',
    port: 443,
    path: path,
    method: 'GET',
    headers: {
      'Authorization': 'GoogleLogin auth=' + googleAuth.getAuthId(),
googleAuth.on(, function(e) {
    switch(e.message) {
      case GoogleClientLogin.errors.loginFailed:
        if (this.isCaptchaRequired()) {
          requestCaptchaFromUser(this.getCaptchaUrl(), this.getCaptchaToken());
        } else {
      case GoogleClientLogin.errors.tokenMissing:
      case GoogleClientLogin.errors.captchaMissing:
        throw new Error('You must pass the both captcha token and the captcha')
    throw new Error('Unknown error');
  // damn..
Something went wrong with that request. Please try again.