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 below is similar to what my method looks like (simplified to make it more clear).
I note that issue 8848 for python seems to be very similar to this problem.
Is the same issue a problem in java api as well? The method
public SuccessCode doSomething(WireFormat wire, User user){
log.info("User id: "+user.getUserId());
log.info("Federated identity: "+user.getFederatedIdentity());
log.info("Email address: "+user.getEmail());
}
will show null for federated identity and userId even though credentials in android client have had oauth2 authentication performed. The email address shows up correctly in the log. This is all on a deployed application btw.
Anybody have any other suggestions as to what is wrong? Any known workarounds for the issue? I have followed the method suggested in https://developers.google.com/appengine/docs/java/endpoints/consume_android#making-authenticated-calls to set up my android client.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With