You should be able to use the existing python client libraries. According to the docs:
"""Token object for OAuth 2.0 as described on <http://code.google.com/apis/accounts/docs/OAuth2.html>. Token can be applied to a gdata.client.GDClient object using the authorize() method, which then signs each request from that object with the OAuth 2.0 access token. This class supports 3 flows of OAuth 2.0: Client-side web flow: call generate_authorize_url with `response_type='token'' and the registered `redirect_uri'. Server-side web flow: call generate_authorize_url with the registered `redirect_url'. Native applications flow: call generate_authorize_url as it is. You will have to ask the user to go to the generated url and pass in the authorization code to your application. """ If I have a chance, I can try to put together some sample code that will do this. On Mon, Jun 1, 2015, 11:53 PM Awais Jibran <awaisdar...@gmail.com> wrote: > Python Version please? > > > > On Monday, 1 June 2015 23:36:57 UTC+5, gramps...@gmail.com wrote: >> >> Hi, >> >> Here's the full example of a method which uploads an image into an >> existing album in Picasa Web Albums. Feel free to share it! >> >> Cheers, >> Gizmo >> >> public static String upload(String fullpathToImage) >> { >> //The url of the image >> String resultingURL = new String(); >> >> try >> { >> >> // These are not needed >> String GOOGLE_APP_NAME = "TralhasVariasScanPoster"; >> >> String GOOGLE_REFRESH_TOKEN = ""; >> String GOOGLE_ACCESS_TOKEN = ""; >> >> HttpTransport httpTransport = new NetHttpTransport(); >> JsonFactory jsonFactory = new JacksonFactory(); >> TokenResponse tokenResponse = new TokenResponse(); >> >> //Check of we have a previous Refresh Token cached >> if (Config.GOOGLE_OAUTH_REFRESH_TOKEN.length() == 0) >> { >> //No Google OAuth2 Key has been previously cached >> >> //Request the user to grant access to the Picasa Resource >> (uses the Google Authentication servers) >> AuthorizationCodeFlow.Builder codeFlowBuilder = >> new >> GoogleAuthorizationCodeFlow.Builder(httpTransport, >> jsonFactory, >> Config.GOOGLE_CLIENT_ID, >> Config.GOOGLE_CLIENT_SECRET, >> >> Arrays.asList(Config.GOOGLE_SCOPE_PICASA)); >> >> AuthorizationCodeFlow codeFlow = codeFlowBuilder.build(); >> AuthorizationCodeRequestUrl authorizationUrl = >> codeFlow.newAuthorizationUrl(); >> >> authorizationUrl.setRedirectUri(Config.GOOGLE_REDIRECT_URI); >> >> System.out.println("Go to the following address:\n" + >> authorizationUrl); >> System.out.println("What is the 'code' url parameter?"); >> String code = new Scanner(System.in).nextLine(); >> >> //Use the code returned by the Google Authentication >> Server to generate an Access Code >> AuthorizationCodeTokenRequest tokenRequest = >> codeFlow.newTokenRequest(code); >> tokenRequest.setRedirectUri(Config.GOOGLE_REDIRECT_URI); >> tokenResponse = tokenRequest.execute(); >> >> GOOGLE_REFRESH_TOKEN = tokenResponse.getRefreshToken(); >> GOOGLE_ACCESS_TOKEN = tokenResponse.getAccessToken(); >> >> //Store the Refresh Token for later usage (this avoid >> having to request the user to >> //Grant access to the application via the webbrowser again >> saveTextFile(Config.GOOGLE_OAUTH_REFRESH_TOKEN_FILE, >> GOOGLE_REFRESH_TOKEN); >> } >> else >> { >> //There is a Google OAuth2 Key cached previously. >> //Use the refresh token to get a new Access Token >> >> //Get the cached Refresh Token >> GOOGLE_REFRESH_TOKEN = new >> String(Config.GOOGLE_OAUTH_REFRESH_TOKEN); >> >> //Now we need to get a new Access Token using our >> previously cached Refresh Token >> RefreshTokenRequest refreshTokenRequest = new >> RefreshTokenRequest(httpTransport, >> >> jsonFactory, >> new >> GenericUrl(Config.GOOGLE_TOKEN_SERVER_URL), >> >> GOOGLE_REFRESH_TOKEN); >> >> refreshTokenRequest.setClientAuthentication(new >> BasicAuthentication(Config.GOOGLE_CLIENT_ID, Config.GOOGLE_CLIENT_SECRET)); >> >> refreshTokenRequest.setScopes(Arrays.asList(Config.GOOGLE_SCOPE_PICASA)); >> >> tokenResponse = refreshTokenRequest.execute(); >> >> //Get and set the Refresn the Access Tokens >> GOOGLE_ACCESS_TOKEN = new >> String(tokenResponse.getAccessToken()); >> } >> >> //At this point we have a valid Google Access Token >> //Let us access Picasa then! >> GoogleCredential credential = new GoogleCredential.Builder() >> .setClientSecrets(Config.GOOGLE_CLIENT_ID, >> Config.GOOGLE_CLIENT_SECRET) >> .setJsonFactory(jsonFactory) >> .setTransport(httpTransport) >> .build() >> .setAccessToken(GOOGLE_ACCESS_TOKEN) >> .setRefreshToken(GOOGLE_REFRESH_TOKEN); >> >> PicasawebService picasaWebSvc = new >> PicasawebService("GOOGLE_APP_NAME"); >> picasaWebSvc.setOAuth2Credentials(credential); >> >> URL feedUrl = new URL(" >> https://picasaweb.google.com/data/feed/api/user/" + >> Config.PICASAWEB_LOGIN + "/albumid/" + Config.PICASAWEB_ALBUM_ID); >> >> MediaFileSource myMedia = new MediaFileSource(new >> File(fullpathToImage), "image/jpeg"); >> PhotoEntry returnedPhoto = picasaWebSvc.insert(feedUrl, >> PhotoEntry.class, myMedia); >> >> resultingURL = >> returnedPhoto.getMediaContents().get(0).getUrl(); >> >> if (resultingURL.toLowerCase().contains("please check your >> firewall") || resultingURL.toLowerCase().contains("error")) >> { >> throw new Exception("The Windows Firewall seems to be >> blocking the upload..."); >> } >> >> System.out.println("...DONE!"); >> System.out.println("Cover page URL: " + resultingURL); >> } >> catch (Exception e) >> { >> System.err.println("[BloggerImageUploader.java]: There was an >> error: " + e.getMessage()); >> return ""; >> } >> >> //The result >> return resultingURL; >> } >> > -- > 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 google-picasa-data-api+unsubscr...@googlegroups.com. > To post to this group, send email to > google-picasa-data-api@googlegroups.com. > Visit this group at http://groups.google.com/group/google-picasa-data-api. > For more options, visit https://groups.google.com/d/optout. > -- 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 google-picasa-data-api+unsubscr...@googlegroups.com. To post to this group, send email to google-picasa-data-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.