I have a problem with getting the userid for a cloud endpoint method. I have used oauth2 authentication in my android client and passed the credentials to my service. The be
I followed the same document reference in the question and had the same exact problem.
Finally got the Endpoints working with OAuth2 by doing the following:
There was an update for Google Play Services which I updated to; now on version 15 (Android SDK).
The endpoint documentation was updated to state that you should enable the Google Plus APIs for your application, even if you just using userinfo.email scope for your app engine endpoints. I did this via the Cloud Console.
Also, finally, there was a new note stating that OAuth2 does not work from the emulator. I confirmed this. I still get the null user error from an Android Emulator, even when pointing to the production app engine. So I can still only test endpoints from a real device.
I was able to confirm that I needed all three of the above steps.
You're correct that issue 8848 is the same cause. The underlying issue is language-agnostic and affects both runtimes. At the moment you shouldn't expect the user ID field populated in a User
object passed in via method argument in Endpoints.
A super suboptimal workaround is to persist the User
object to the datastore and read it back. The re-read object will have the user ID included.