}
public static void auth() throws Exception {
flash.keep(REDIRECT_URL);
ServiceInfo serviceInfo = Dropbox.OAUTH;
OAuth oauth = OAuth.service(serviceInfo);
OAuth.Response oauthResponse = oauth.retrieveRequestToken();
if (oauthResponse.error == null) {
Logger.info("Redirecting to Dropbox for auth.");
session.put(SessionKeys.TOKEN, oauthResponse.token);
session.put(SessionKeys.SECRET, oauthResponse.secret);
redirect(oauth.redirectUrl(oauthResponse.token) +
"&oauth_callback=" +
URLEncoder.encode(request.getBase() + "/auth-cb", "UTF-8"));
} else {
Logger.error("Error connecting to Dropbox: " + oauthResponse.error);
error("Error connecting to Dropbox.");