I got some code working. Here is how, for those interested. I borrowed the 
first 6 steps from another thread.

Get a client id and client secret
1. Log into the Google developers console:  
https://console.developers.google.com/project
2. Click the Create Project button and give it a name
3. If the left hand menu select Credentials under the APIs and auth menu
4. Under the OAuth heading select Create New Client ID
5. Select Application Type = other and click the Create button
6. Record the Client ID and the Client Secret

Now for the program logic
1. Get the user to login into google via special url in webbrowser and get 
a code. The user has to enter that code into your application.
2. Use the given code, client id and client secret to get a token from 
google url. The token has a limited lifespan.
3. Use token to authenticate with PicasawebService so that you can fetch 
your precious data from google

There is the java 1.8 code:
------
class Test {
   private Credential.AccessMethod accessMethod = 
BearerToken.authorizationHeaderAccessMethod();  
   private NetHttpTransport httpTransport = new NetHttpTransport();
   private JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
   private GenericUrl tokenServerUrl = new 
GenericUrl(GoogleConstants.REQUEST_TOKEN_URL + 
GoogleConstants.REQUEST_TOKEN_PARAMS  );
   private String authorizationServerEncodedUrl = 
encodeURL(GoogleConstants.USER_AUTHENTICATION_URL);
   private HttpExecuteInterceptor httpExecuteInterceptor = httpRequest -> 
{};

   /**
    * @param code Enduser has to visit and log in on special google url to 
get a code. Pass that code as argument here.
    * Url for user to visit is 
"https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2F&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id="+GoogleConstants.CLIENT_ID
    */
   public void test(String code) throws Exception {
       AuthorizationCodeFlow.Builder builder = new 
AuthorizationCodeFlow.Builder(
               accessMethod,
               httpTransport,
               jsonFactory,
               tokenServerUrl,
               httpExecuteInterceptor,
               GoogleConstants.CLIENT_NAME,
               authorizationServerEncodedUrl);
       AuthorizationCodeFlow flow = builder.build();
       AuthorizationCodeTokenRequest authorizationCodeTokenRequest = 
flow.newTokenRequest(code);
       TokenResponse token = authorizationCodeTokenRequest.execute();

       PicasawebService service = new 
PicasawebService(GoogleConstants.CLIENT_NAME);
       service.setAuthSubToken(token.getAccessToken());
       
       //now you can finally do stuff:
       
       URL feedUrl = new 
URL("https://picasaweb.google.com/data/feed/api/user/default?kind=album";);
       UserFeed myUserFeed = service.getFeed(feedUrl, UserFeed.class);
       //etc etc
       
       
    }
}
------
public class GoogleConstants {
    public static final String CLIENT_NAME = "projectname";
    public static final String CLIENT_ID = "yourclientid";
    public static final String CLIENT_SECRET = "yourclientsecret";
    public static final String REQUEST_TOKEN_URL = 
"https://www.googleapis.com/oauth2/v3/token";;
    public static final String REQUEST_TOKEN_PARAMS = "?client_id=" + 
CLIENT_ID + "&client_secret=" + CLIENT_SECRET + 
"&redirect_uri=urn:ietf:wg:oauth:2.0:oob";
    public static final String USER_AUTHENTICATION_URL = 
"https://accounts.google.com/o/oauth2/v2/auth";;
}
------
I used some libs from maven central because I'm too lazy to build them 
myself from source. Hopefully they are up to date. Here are the required 
maven dependencies:
    <dependencies>
        <dependency>
            <groupId>com.google.gdata</groupId>
            <artifactId>core</artifactId>
            <version>1.47.1</version>
        </dependency>

        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client-assembly</artifactId>
            <version>1.21.0</version>
        </dependency>
    </dependencies>


Op vrijdag 15 januari 2016 17:20:12 UTC+1 schreef ggvw:
>
> Hi,
>
> I'm trying to make a java application that can export the photo commentary 
> from picasa to a local file on the harddisk. As I see it, I need a instance 
> of PicasawebService in order to do that. 
> Unfortunatly, a lot of documentation about it's use seems to be outdated. 
> Even the examples shipped with the API don't seem to work because it looks 
> like picasawebservice.setUserCredentials(username, password) is no longer 
> supported.
>
> Is there anyone who knows an up-to-date tutorial or working code example 
> of creating an instance of Picasaweb or authenticating with the Picasa API?
>
>
> Regards,
>  Gijs
>
>

-- 
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 https://groups.google.com/group/google-picasa-data-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to