System.out.println("frob: " + frob);
final URL url = authInterface.buildAuthenticationUrl(Permission.DELETE, frob);
System.out.println("Press return after you granted access at this URL:");
System.out.println(url.toExternalForm());
final Stage stage = Stage.createStage();
stage.setContent(
new GridBox()
.createColumn(50,GridBox.Align.Right)
.createColumn(50,GridBox.Align.Fill)
.addControl(new Label("Please visit Flickr and grant Leo access to your account"))
.nextRow()
.addControl(new Spacer())
.addControl(new Button("Goto Flickr").onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent event) {
OSUtil.openBrowser(url.toExternalForm());
}
}))
.nextRow()
.addControl(new Button(getString("dialog.cancel")).onClicked(new Callback<ActionEvent>(){
public void call(ActionEvent event) {
stage.hide();
}
}))
.addControl(new Button("Continue >").onClicked(new Callback<ActionEvent>(){
public void call(ActionEvent event) {
stage.hide();
try {
Auth auth = authInterface.getToken(frob);
System.out.println("Authentication success");
// This token can be used until the user revokes it.
System.out.println("Token: " + auth.getToken());
String user_token = auth.getToken();
ChangeFlickrSettingsAction.this.context.getSettings().setProperty(FLICKR_USER_TOKEN,user_token);
String user_id = auth.getUser().getId();
ChangeFlickrSettingsAction.this.context.getSettings().setProperty(FLICKR_USER_ID,user_id);
System.out.println("nsid: " + auth.getUser().getId());
System.out.println("Realname: " + auth.getUser().getRealName());
System.out.println("Username: " + auth.getUser().getUsername());
System.out.println("Permission: " + auth.getPermission().getType());
} catch (FlickrException e) {
System.out.println("Authentication failed");
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}))
);
stage.setWidth(400);
stage.setHeight(200);
}