How to stay signed in with the oAuth2 for an automatic reporting tool

3,093 views
Skip to first unread message

Remco Borst

unread,
Mar 22, 2013, 12:10:22 PM3/22/13
to google-analytics...@googlegroups.com
Hi people,
 
Is it possible to stay logged in in any way with the google API ?
 
I'm trying to make an automatic reporting tool using the google adwords API ( irrelevant to this question ) and the google analytics API.
There is only one problem.. everytime i run the script.. and if i have not yet authenticated the request it asks me to give permission again.
It should be possible to grant permission to a certain url or project or what ever for ever.
 
Does anyone know if this is possible?
 
Kind regards,
Remco Borst

chris@shufflepoint

unread,
Apr 17, 2013, 2:58:17 PM4/17/13
to google-analytics...@googlegroups.com
OAuth 2 refresh tokens do not expire.

sankar....@gmail.com

unread,
Apr 24, 2013, 10:10:08 AM4/24/13
to google-analytics...@googlegroups.com
 
We are developing a windows service to retrieve the Google analytics data using "Google.Apis.Analytics.v3.cs" API in C#.
We can't open the browser through windows service even once. Is there a solution for our problem. We want our system
fully automated that we want to avoid opening the browser to generate credential even once.
 
Can you share the simple steps or the sample c# code to auto-authenticate.

Aaron Toledo

unread,
Apr 24, 2013, 10:45:16 AM4/24/13
to google-analytics...@googlegroups.com
Hi Remco -

I was able to do this with the analytics API and Python library by switching from a Web Application to an Installed Application. Not sure if you're already doing that, but you can set it up from the API Console. You can then specify a redirect_uri of "urn:ietf:wg:oauth:2.0:oob". See http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.client-module.html#flow_from_clientsecrets

Phil Gyford

unread,
Apr 25, 2013, 9:24:35 AM4/25/13
to google-analytics...@googlegroups.com
When you first authenticate you get an access token. From this you can get a request token. The access token expires after an hour. You can then use the request token to fetch a new access token for the user - this doesn't require authenticating again.


And, as an example, this script shows how to do it using Ruby and the Legato gem: https://gist.github.com/jotto/2932998 (Edward's comment shows how to most easily get a new access token using the refresh token.)

Phil

sankar....@gmail.com

unread,
Apr 25, 2013, 11:32:21 AM4/25/13
to google-analytics...@googlegroups.com
Hi Phil,
 
Is there anyway to give access token without user intervention. Becuase my applicatoin is window service, it wont allow browser to give access token.
 
Thanks,
Sankar.

Nick

unread,
Apr 25, 2013, 1:28:15 PM4/25/13
to google-analytics...@googlegroups.com
Yes. Please read these docs: https://developers.google.com/accounts/docs/OAuth2InstalledApp

There are many different options depending on what you need.

-Nick
Reply all
Reply to author
Forward
0 new messages