【问题标题】:Google Drive API JAVA User ClassGoogle Drive API JAVA 用户类
【发布时间】:2015-07-13 13:34:43
【问题描述】:

我正在尝试使用此代码获取 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/Preconditions

【问题讨论】:

标签: java google-drive-api


【解决方案1】:

您的 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    • 2020-07-14
    • 1970-01-01
    相关资源
    最近更新 更多