2015-05-04 165 views
0

我試圖用這個代碼來獲得谷歌驅動器的授權用戶名:谷歌雲端硬盤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

+0

m試圖獲取谷歌驅動器授權用戶的名字 –

+0

請考慮將您的代碼示例縮小爲[最小,完整且可驗證的示例](http://stackoverflow.com/help/m cve)並改進格式以使其更具可讀性。 –

回答

0

codeError不清除的問題,但你可以在下面查找(按評論):

下面的代碼用它來獲得谷歌授權的用戶的用戶名驅動器:

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); 
    } 

You can get more details Here

相關問題