[英]Google Drive API JAVA User Class
我正在嘗試使用以下代碼獲取Google Drive的授權用戶的名稱:
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狀態500-Servlet執行引發異常
有這個特例
javax.servlet.ServletException:Servlet執行引發異常org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因
java.lang.NoClassDefFoundError:com / google / common / base /前提條件
您的code
和Error
未清除問題,但您可能正在下面查找(根據評論):
使用以下代碼獲取Google Drive的授權用戶的用戶名:
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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.