Function User.getUserId() in Cloud endpoint api returns null for a user object that is not null

前端 未结 2 1058
滥情空心
滥情空心 2021-01-02 02:45

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

相关标签:
2条回答
  • 2021-01-02 03:07

    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.

    0 讨论(0)
  • 2021-01-02 03:11

    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.

    0 讨论(0)
提交回复
热议问题