Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle App Engine getCurrentUser() returns null
    primarykey
    data
    text
    <p>I'm developing an application which requires access to all users in the account. All operations are done on the Google Apps for Bussiness account using administrative account.</p> <p>The general idea is to access my application without any login screens/URLs from the dashboard and retrieve necessary data (users in this case). Is that possible?</p> <p>I don't know if I have to set OAuth (my app is deployed on the appspot and added to the GApps account) - like I said earlier I just want to launch my app and it should get login credentials from currently logged GApps user. </p> <p>However getting current user returns null. This is my servlet with method for getting current user:</p> <pre><code>public class ExperimentalServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); resp.setContentType("text/plain"); resp.getWriter().println("User: " + (user == null ? "&lt;null&gt;" : user.getNickname())); } } </code></pre> <p>appengine-web.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;appengine-web-app xmlns="http://appengine.google.com/ns/1.0"&gt; &lt;application&gt;name-of-my-application&lt;/application&gt; &lt;threadsafe&gt;true&lt;/threadsafe&gt; &lt;version&gt;1&lt;/version&gt; &lt;/appengine-web-app&gt; </code></pre> <p>web.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"&gt; &lt;servlet&gt; &lt;servlet-name&gt;experimental&lt;/servlet-name&gt; &lt;servlet-class&gt;my.app.domain.ExperimentalServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;experimental&lt;/servlet-name&gt; &lt;url-pattern&gt;/experimental&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;welcome-file-list&gt; &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;/web-app&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload