Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid + App engine: user.getUserID() is null in endpoint
    primarykey
    data
    text
    <p>I have an Android application with GAE server. I tried to authenticate the user as described on developers.google.com, I added the user parameter to the endpoint methods etc. I get a User which is not null, but this method getUserId() returns null. It is similar to this, rather old problem: <a href="https://stackoverflow.com/questions/16171225/function-user-getuserid-in-cloud-endpoint-api-returns-null-for-a-user-object-t">Function User.getUserId() in Cloud endpoint api returns null for a user object that is not null</a> But I still don't know how to work around it. How do you handle this error? Have you ever encountered it?</p> <p>In android client here's what I did (its simplified) :</p> <pre><code>credentials = GoogleAccountCredential.usingAudience(getApplicationContext(), "server:client_id:" + WEB_CLIENT_ID); credentials.setSelectedAccountName(accountName); WarriorEntityEndpoint.Builder endpointBuilder = new WarriorEntityEndpoint.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credentials); warriorEntityEndpoint = endpointBuilder.build(); new AsyncTask&lt;Void, Void, Void&gt;() { @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub try { warriorEntityEndpoint.getWarrior().execute(); } catch (Exception e) { } return null; } }.execute(); </code></pre> <p>And on GAE:</p> <pre><code>@Api(name = "warriorEntityEndpoint", namespace = @ApiNamespace(ownerDomain = "szpyt.com", ownerName = "szpyt.com", packagePath = "mmorpg.monsters"), version = "version1", scopes = {"https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"}, clientIds = {Constants.ANDROID_CLIENT_ID, Constants.WEB_CLIENT_ID}, audiences = {Constants.ANDROID_AUDIENCE}) public class WarriorEntityEndpoint { private static final Logger log = Logger.getLogger(WarriorEntityEndpoint.class.getName()); @ApiMethod(name = "getWarrior") public WarriorEntity getWarrior(User user) throws OAuthRequestException, IOException { log.log(Level.SEVERE, "this gives correct email: " + user.getEmail()); log.log(Level.SEVERE, "this is null: " + user.getUserId()); </code></pre> <p>I have also another very important question: is this user authenticated, if getMail() gives me correct account, but getUserId() gives null? I read that user object should be null if it was not authenticated but I am not sure any more... I'm using App engine SDK 1.8.7. I'm testing on a real device and backend deployed to GAE.</p>
    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.
 

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