Thanks to your help. It work for me. But I have another problem. Before, when I use gd_client.ProgrammaticLogin() with username and app password ( 2 step verification ), I can get private Album with GetUserFeed .
But now, when I use your function, I can only get public albums. Do you have any idea for this. Thank you On Saturday, June 28, 2014 at 4:47:59 PM UTC+7, [email protected] wrote: > > sample: > > def main(): > gdata_monkey_patch() > > from gdata.photos.service import PhotosService > client = PhotosService() > client_id = 'xxx' > client_secret = 'xxx' > useragent = 'xxx' > gdata_auth(client, client_id, client_secret, ' > https://picasaweb.google.com/data/', useragent) > > username = 'xxx' > print client.GetUserFeed(user=username) > > > def gdata_monkey_patch(): > def _authorize(self, client): > client.auth_token = self > request_orig = client.http_client.request > > #def new_request(http_request): > def new_request(*args, **kwd): > #response = request_orig(http_request) > response = request_orig(*args, **kwd) > if response.status == 401: > refresh_response = self._refresh(request_orig) > if self._invalid: > return refresh_response > else: > #self.modify_request(*args, **kwd) > self.modify_request(*args, **kwd) > #return request_orig(*args, **kwd) > return request_orig(*args, **kwd) > else: > return response > > client.http_client.request = new_request > return client > > from gdata import gauth > gauth.OAuth2Token.authorize = _authorize > > > def gdata_auth(client, client_id, client_secret, scope, useragent): > from os.path import exists > token_path = __file__ + '.gdata.token' > if not exists(token_path): > from gdata.gauth import OAuth2Token > token = OAuth2Token( > client_id=client_id, > client_secret=client_secret, > scope=scope, > user_agent=useragent) > > url = > token.generate_authorize_url(redirect_uri='urn:ietf:wg:oauth:2.0:oob') > > from webbrowser import open as webopen > webopen(url) > > code = raw_input('code:') > token.get_access_token(code) > > with file(token_path, 'w') as writable: > from gdata.gauth import token_to_blob > writable.write(token_to_blob(token).encode('UTF-8')) > else: > with file(token_path) as readable: > from gdata.gauth import token_from_blob > token = token_from_blob(unicode(readable.read(), 'UTF-8')) > > token.authorize(client) > > main() > -- You received this message because you are subscribed to the Google Groups "Google Picasa Web Albums API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.
