That is correct, the refresh token is long lived and last until the user
revokes access.

Best,
Alain

On Fri, Aug 26, 2011 at 10:35 AM, Tasmania <[email protected]> wrote:

> Alain,
>
> You are a life saver ... thanks! it worked just fine.
> I'm assuming I can authenticate over and over with these credentials
> without having to refresh them until the user revokes our permission,
> right?
>
> Thanks again
>
>
> Marcelo
>
> On Aug 26, 9:01 am, Alain Vongsouvanh <[email protected]> wrote:
> > Hello,
> >
> > If you already have the access and refresh tokens, you don't have to
> request
> > another one and can directly authorize your
> > gdata.calendar.client.CalendarClient:
> >   token
> > =
> gdata.gauth.OAuth2Token(client_id=client_id,client_secret=client_secret',
> > scope='https://www.google.com/calendar/feeds',
> >
> >  user_agent='calendar-cmdline-sample/1.0', access_token='<ACCESS_TOKEN>',
> > refresh_token='<REFRESH_TOKEN>')
> >
> >   token.authorize(client)
> >
> > Best,
> > Alain
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Aug 25, 2011 at 7:08 PM, Tasmania <[email protected]> wrote:
> > > hi there,
> >
> > > I'm migrating my Python application that reads a user's Google
> > > calendar feed from oAuth 1 to oAuth 2.
> >
> > > * With oAuth 1:
> > > My app would open a browser were user can authenticate with his GMail
> > > account and authorize access, and my app would obtain a user_token,
> > > user_secret for that user, then authenticate to the calendar feed:
> >
> > > client = gdata.calendar.client.CalendarClient(source='test')
> > > client.auth_token = gdata.gauth.OAuthHmacToken(app_key,
> > > app_secret,user_token,user_secret,gdata.gauth.ACCESS_TOKEN)
> >
> > > This token, secret pair would be long lived.
> >
> > > * With oAuth 2:
> > > I registered my app in the Google API console and obtained the oAuth 2
> > > client_id and client_secret, and modified the app to request the
> > > user's access_token, refresh_token from
> > >https://accounts.google.com/o/oauth2/token
> > > For the GData lib, I applied the gauth.py patch specified here:
> > >http://codereview.appspot.com/4440067/
> >
> > > This access_token is short lived.
> >
> > > I played a little bit with the code posted here
> > >http://codereview.appspot.com/4440067/
> > > and works ok.
> >
> > > My questions:
> > > 1. I am obtaining access_token, refresh_token via a curl call from my
> > > app, and I can successfully retrieve both. However, when I apply it to
> > > this code:
> >
> > > token =
> > >
> gdata.gauth.OAuth2Token(client_id=client_id,client_secret=client_secret',
> > >                                scope='https://www.google.com/calendar/
> > > feeds',
> > >                                user_agent='calendar-cmdline-sample/
> > > 1.0')
> > > uri = token.generate_authorize_url()
> > > token.get_access_token(access_token)
> >
> > > It gives me:
> >
> > > Traceback (most recent call last):
> > >  File "<stdin>", line 1, in <module>
> > >  File "/Library/Python/2.6/site-packages/gdata/gauth.py", line 1267,
> > > in get_access_token
> > >    raise OAuth2AccessTokenError(error_msg)
> > > gdata.gauth.OAuth2AccessTokenError
> >
> > > 2. Assuming I can successfully do #1, I can save the access/refresh
> > > tokens in a DB. Using python gdata lib, how can I use refresh_token to
> > > request another access_token (hence not having to ask the user every
> > > time they use the app to authorize access to it)
> >
> > > Thanks much in advance!
> >
> > > M
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Google Calendar Data API" group.
> > > To post to this group, send email to
> > > [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://code.google.com/apis/calendar/community/forum.html
> >
> > --
> > Alain Vongsouvanh
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Calendar Data API" group.
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://code.google.com/apis/calendar/community/forum.html
>



-- 
Alain Vongsouvanh

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to