本文整理汇总了Java中com.flickr4java.flickr.util.FileAuthStore类的典型用法代码示例。如果您正苦于以下问题:Java FileAuthStore类的具体用法?Java FileAuthStore怎么用?Java FileAuthStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileAuthStore类属于com.flickr4java.flickr.util包,在下文中一共展示了FileAuthStore类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import com.flickr4java.flickr.util.FileAuthStore; //导入依赖的package包/类
public static Auth authorize(Flickr flickr, File authDirectory, String username) throws IOException, SAXException, FlickrException {
AuthStore authStore = new FileAuthStore(authDirectory);
Auth auth = authStore.retrieve(flickr.getPeopleInterface().findByUsername(username).getId());
if (auth != null) {
RequestContext.getRequestContext().setAuth(auth);
return auth;
}
AuthInterface authInterface = flickr.getAuthInterface();
Token accessToken = authInterface.getRequestToken();
String url = authInterface.getAuthorizationUrl(accessToken, Permission.READ);
System.out.println("Please visit the following URL to get your authorization token:");
System.out.println();
System.out.println(url);
System.out.println();
System.out.print("Enter your token: ");
String tokenKey = new Scanner(System.in).nextLine();
Token requestToken = authInterface.getAccessToken(accessToken, new Verifier(tokenKey));
auth = authInterface.checkToken(requestToken);
RequestContext.getRequestContext().setAuth(auth);
authStore.store(auth);
return auth;
}
示例2: Upload
import com.flickr4java.flickr.util.FileAuthStore; //导入依赖的package包/类
public Upload(File authsDir) throws FlickrException, IOException {
Properties properties;
InputStream in = null;
try {
in = Upload.class.getResourceAsStream("setup.properties");
properties = new Properties();
properties.load(in);
} finally {
IOUtilities.close(in);
}
flickr = new Flickr(properties.getProperty("apiKey"),
properties.getProperty("secret"), new REST());
this.nsid = properties.getProperty("nsid");
if (authsDir != null) {
this.authStore = new FileAuthStore(authsDir);
}
}
示例3: GUI
import com.flickr4java.flickr.util.FileAuthStore; //导入依赖的package包/类
public GUI() throws FlickrException {
isRunning = false;
sizes = new ImageSizes();
flickr = new Flickr(FlickrConfig.API_KEY, FlickrConfig.SECRET_KEY, new REST());
flickrAuth = new FileAuthStore(Settings.getAuthDirectory());
initComponents();
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
updateComponents();
}