谷歌云端硬盘API的Java用户类
问题描述:
我试图用这个代码来获得谷歌驱动器的授权用户名:谷歌云端硬盘API的Java用户类
public class list extends HttpServlet{
private DbxClient client;
String token;
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException{
try{
DbxRequestConfig requestConfig = new
DbxRequestConfig("JavaDropBoxTutorial/1.0",Locale.getDefault().toString());
HttpSession session = req.getSession();
token = session.getAttribute("access_token").toString();
client = new DbxClient(requestConfig, token);
session.setAttribute("dropuser",client.getAccountInfo().displayName);
User u = new User();
System.out.print(u.getDisplayName());
res.sendRedirect("listdetails.jsp");
}
catch(Exception e){
}
}
}
但我得到这个错误: -
HTTP Status 500 - Servlet execution threw an exception
随着例外
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根源
java.lang.NoClassDefFoundError: com/google/common/base/Preconditions
答
你code
和Error
不清除的问题,但你可以在下面查找(按评论):
下面的代码用它来获得谷歌授权的用户的用户名驱动器:
try {
About about = service.about().get().execute();
System.out.println("Current user name: " + about.getName());
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
m试图获取谷歌驱动器授权用户的名字 –
请考虑将您的代码示例缩小为[最小,完整且可验证的示例](http://stackoverflow.com/help/m cve)并改进格式以使其更具可读性。 –