0

On android client, I create Credentials, then choose account using AccountPicker and set the account name. On GAE, I have User parameter in every endpoint method. (I described it here) Android Client ID, Web client ID and audiences are configured correctly. On endpoint, the user is not null and has correct email set. But when I call user.getUserId() I get null. Is this user authenticated or not?... It really makes me nervous not to know that...

Community
  • 1
  • 1
user2855896
  • 270
  • 2
  • 11

2 Answers2

0

What you describe is odd, and I don't know why you get null when you call getUserId(), but never-the-less I would say, Yes, you are authenticated.

If you want to be sure, then you could try using that authentication from a web client - I read that once you have authenticated an Android user you are automatically given minimal account authentication for web too. So create a minimal servlet that includes the following code:

UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();

Load the page while signed in with the same account you authenticated from Android and see whether it acts like it already knows you, or whether it prompts the user as it would for a different, un-authenticated user.

Tom
  • 17,103
  • 8
  • 67
  • 75
0

This is a bug on google's side.

There seems to be a clunky workaround: save User to datastore and read it back.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154