My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google Analytics (Labs)

Data Export API - Authorization

  1. Overview
  2. Which Authorization Method Should You Use?
  3. Understanding ClientLogin
  1. Understanding AuthSub
  2. Understanding oAuth

Overview

Before users can view data from an application that uses the Data Export API, they must access Google Analytics using a Google Account. Authorization starts when a user provides a username and password (login credentials). Your application uses the login credentials to request an authorization token from the Google Authorization API. The URL for this request is https://www.google.com/analytics/feeds . Note that analytics is part of the authorization URL as the specific service being accessed.

The authorization process verifies three things:

  1. The user has supplied the required credentials for their Google Account.
  2. The same credentials are linked to an Analytics user account.
  3. The user is authorized to access the profile indicated in the data feed URL.

If the user is not authorized to view either the account or the profile data, the server returns an error. Once the authorization token is received, it can be used to access a user's data on their behalf, without having to send credentials on subsequent requests.

The Google Analytics Export API supports the following authorization services, all of which are described in the Google Data API Authentication Overview:

  • ClientLogin username/password authentication, for applications that run on a user's computer
  • AuthSub proxy authorization
  • OAuth authorization

Which Authorization Method Should You Use?

When writing an application that uses the Google Analytics Data Export API, you should consider both the client library you are using as well as the purpose of the application. The following table summarizes the three supported authentication methods for the Google Analytics Data Export API, with the relevant libraries and application purpose for each.

  Protocol
Support
Java
Support
JavaScript
Support
ClientLogin Yes Yes No
AuthSub Yes Yes Yes
OAuth Yes Yes Limited*

*Because OAuth requires a signature, and the signature key cannot be kept secure in a JavaScript environment, there is no native support for OAuth in Javascript. However, JavaScript support for the OAuth Proxy is available in Shindig, where a Shindig server can make OAuth requests on behalf of a gadget. The OAuth proxy is currently supported in iGoogle. For more information on how to build a gadget using the Google Data client and the OAuth Proxy, see Creating a Google Data Gadget.

For more information on determining which type of authentication you should use, see Getting Started with Account Authorization.

Understanding ClientLogin

ClientLogin is the simplest way to access the Data Export API; you simply provide your user name and password. Use ClientLogin in the following situations:

  • You are starting to explore the Data Export API and you want to get going quickly, using your own credentials.
  • You are building a single-user application that will be installed on a computer, not on the web.
  • You want to share your data with others. In this case, you provide your own credentials to retrieve the data, and you share the data results with other people, who do not log in to Analytics via your application, but merely access the display of data you have provided.

Important: Do not use ClientLogin if you are writing an application that runs on your computer to make requests on behalf of 3rd party end users. Instead, use either AuthSub or OAuth, which protects end users' private data. Because ClientLogin stores the user login data, it should only be used in cases where that data is under the direct control of the user (e.g. their personal computer).

ClientLogin is available in the following development environments. Click on each link to see details.

  • HTTP Protocol Details Show rest of description Hide rest of description
  • Java Client Library Show rest of description Hide rest of description

Note: Use the same token for all requests in a given session; don't acquire a new token for each Analytics request.

More Information on ClientLogin

Understanding AuthSub

AuthSub proxy authorization is used by web applications that need to access a user's Google Account. With AuthSub, the website operator and the client code never see the user's username and password. Instead, the client obtains special AuthSub tokens which it uses to act on a particular user's behalf. For this reason you should use the AuthSub method if you are building a web application to access data through other people's credentials. This ensures you respect users' private data and adhere to our Terms of Service. In addition, the end user can revoke access by the 3rd party access at any time. Users can do this by logging in at http://google.com/accounts, going to Personal Settings -> Security -> Change Authorized Websites, and removing access for any of the listed services.

For detailed information, see the Authentication for Web Applications documentation.

Note: You should not use this method if you want to login with your own credentials and share data with others.

This method of account access is available in the following development environments. Click on each link to see details.

  • HTTP Protocol Details Show rest of description Hide rest of description
  • Java Show rest of description Hide rest of description
  • JavaScript Client Library (default authorization method) Show rest of description Hide rest of description

More Information on AuthSub

Understanding OAuth

The OAuth authorization method is an open protocol for authorization in both desktop and web-based applications. Like AuthSub, OAuth enables the application to get an access token without ever handling the user's credentials. Unlike AuthSub, you are required to register your application with a security certificate in order to use OAuth. The OAuth website contains a clear descripton of the most common use cases for OAuth. Consider using OAuth in the following situations:

  • You are developing your application as a gadget that will run on a website that supports OAuth, or you are writing a gadget designed to run in an OpenSocial environment. See Writing OAuth Gadgets for details.
  • You are developing your application to a variety of different clients (installed, web, mobile).
  • You are developing your application in an environment that uses a variety of services from multiple providers.

More Information on OAuth

Back to Top