String.format("/authorize?response_type=code&client_id=%s&redirect_uri=%s",
CLIENT_ID, WS.encode(Router.getFullUrl("Login.boxAuthCallback")));
}
public static BoxCredentials getCred(String code) {
WSRequest ws = WS.url(URLs.BASE_V2_OAUTH + "/token")
.setParameter("grant_type", "authorization_code")
.setParameter("code", code)
.setParameter("client_id", CLIENT_ID)
.setParameter("client_secret", CLIENT_SECRET);
HttpResponse resp = ws.post();
if (resp.success()) {
return new Gson().fromJson(resp.getJson(), BoxCredentials.class);
}
throw new IllegalStateException("Failed fetching box account credentials. Status: " + resp.getStatus() +