logging in

296 views
Skip to first unread message

msh210

unread,
Dec 11, 2011, 7:20:26 PM12/11/11
to google-analytics-api - GA Data Export API
I've been accessing the Data Export API through a bash script that

* got an authentication token from https://www.google.com/accounts/ClientLogin
using curl,
* parsed the response for the token,
* and then used curl again (and that token) to get the data.

(The script is posted at http://stackoverflow.com/q/8465674/552647 ,
which also has this question worded differently, in case the version
here is unclear.)

Is that possible with version 3.0? I can't seem to find any
documentation that relates to how to do it.

Thanks.

Nick

unread,
Dec 13, 2011, 12:48:07 PM12/13/11
to google-analytics-api - GA Data Export API
Per the link, yes your "script" would be considered an application.

In version 3.0 we're supporting OAuth 2.0. Consider how the OAuth 2.0
flow works:

Each OAuth 2.0 authorized request must include an access token to the
server. This requires a user to go to a google.com domain, login,
authorize access to an app and then get an authorization token. You
put the authorization token back in your installed app, and use the
auth token to get a refresh and access token. You save the refresh
token. The access token can be used to make requests for a period of
time. Once they expire (the API returns a 401) you need to use the
refresh token to get a new access token.

So you could have a (few?) shell scripts which have a couple of parts
to:
1 - get and save an access / refresh token
2 - use the access tokens to make API requests
3 - use the refresh token to get and save a new access token

Alternatively you could use one of our client libraries which handle
all of this for you: http://code.google.com/apis/analytics/docs/gdata/v3/gdataLibraries.html

-Nick

On Dec 11, 4:20 pm, msh210 <msh...@gmail.com> wrote:
> I've been accessing the Data Export API through a bash script that
>

>  * got an authentication token fromhttps://www.google.com/accounts/ClientLogin

Reply all
Reply to author
Forward
0 new messages