To make authenticated calls using flickrj api, you need, in addition to your apiKey and secret, a third code, a token .
We get the token with a one-time first call, and then with the token in your hand, you can simply use the api classes, as you would expect.
If you have ever used the flickr iOS / Android client, you will find out: the first time you use the application, it will send you a URL for you to authorize. What does he do when you authorize him, he gets this token , and then it's good to go. Without it, he is not. The same goes for your java application.
I used this example implementation for this first step authentication with a few modifications, though, since I am working in a Spring MVC application, not a desktop application. Remember that you only run once, and the only point to this is to get the token key.
https://github.com/mohlendo/flickrj/blob/master/examples/AuthExample.java
Line 55:
frob = authInterface.getFrob();
The sole purpose of frob is to use it to create an authentication URL, see line 60:
URL url = authInterface.buildAuthenticationUrl(Permission.DELETE, frob);
I did this in a Spring MVC application, not a desktop application, so after line 60, I instead typed the URL into System.out and then paused the program for a minute using Thread.sleep(60000);
This gave me enough time to copy the URL from my console to the browser and click "OK so my application can use my flickr account."
Right after that, when the program resumes everything I cared about, there was line 70 that prints the token on the console.
With a token in my hand, authorization is complete, and I was configured to use the Flickrj api.
With three keys in hand (apiKey, secret, token) here is my Service class with a static method for creating a Flickr object.
import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.xml.parsers.ParserConfigurationException; import com.aetrion.flickr.Flickr; import com.aetrion.flickr.REST; import com.aetrion.flickr.RequestContext; import com.aetrion.flickr.auth.Auth; import com.aetrion.flickr.auth.Permission; import com.aetrion.flickr.util.IOUtilities; public class FlickrjService { private static Flickr flickr; public static Flickr getFlickr() throws ParserConfigurationException, IOException { InputStream in = null; Properties properties; try { in = FlickrjService.class.getResourceAsStream("/flickrj.properties"); properties = new Properties(); properties.load(in); } finally { IOUtilities.close(in); } flickr = new Flickr(properties.getProperty("flickrj.apiKey"), properties.getProperty("flickrj.secret"), new REST("www.flickr.com")); RequestContext requestContext = RequestContext.getRequestContext(); Auth auth = new Auth(); auth.setPermission(Permission.READ); auth.setToken(properties.getProperty("flickrj.token")); requestContext.setAuth(auth); Flickr.debugRequest = false; Flickr.debugStream = false; return flickr; } }