npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

googleclientlogin

v0.2.8

Published

Log in to Google services using CllientLogin method

Downloads

7,173

Readme

Google's ClientLogin authentication implementation for Node.js

Requires at least nodejs 0.4.1

Properties:

errors:

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

accountTypes:

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

Events:

login:

emitted when login was success

error:

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

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

Methods:

login

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

getAuthId

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(),

getSID

Returns the value of SID key from the response.

getLSID

Returns the value of LSID key from the response.

isCaptchaRequired

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

getCaptchaUrl

Url of the captcha image

getCaptchaToken

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.

getError

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

http://code.google.com/apis/gdata/faq.html#clientlogin

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: '[email protected]',
  password: 'yourpassword',
  service: 'contacts',
  accountType: GoogleClientLogin.accountTypes.google
});
googleAuth.on(GoogleClientLogin.events.login, function(){
  // do things with google services
  require('https').request({
    host: 'www.google.com',
    port: 443,
    path: path,
    method: 'GET',
    headers: {
      'Authorization': 'GoogleLogin auth=' + googleAuth.getAuthId(),
      ...
    }
  });
});
googleAuth.on(GoogleClientLogin.events.error, function(e) {
    switch(e.message) {
      case GoogleClientLogin.errors.loginFailed:
        if (this.isCaptchaRequired()) {
          requestCaptchaFromUser(this.getCaptchaUrl(), this.getCaptchaToken());
        } else {
          requestLoginDetailsAgain();
        }
        break;
      case GoogleClientLogin.errors.tokenMissing:
      case GoogleClientLogin.errors.captchaMissing:
        throw new Error('You must pass the both captcha token and the captcha')
        break;
    }
    throw new Error('Unknown error');
  // damn..
});
googleAuth.login();