1

I am using OAuth with my app-engine server. It's rather simple to do, simple add User as one of the parameters. But when I do I get the compile error

Multiple entity parameters. there can only be a single entity parameter per method...

@ApiMethod(path = "updateDocument", name = "updateDocument", httpMethod = ApiMethod.HttpMethod.POST)
public void updateDocument(User user, MyDocument input){
  ...
}

It works fine for the methods of the form

public MyBean sayHiUser(@Named("name") String name, User user)

It just doesn't work when I have custom objects like MyDocument.

Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199

1 Answers1

2

I have the feeling your User is not of type import com.google.appengine.api.users.User.

The documentation states that "there can only be a single entity parameter per method" (see https://cloud.google.com/appengine/docs/java/endpoints/parameter-and-return-types).

However "Any type except a parameter or injected type is considered an entity type" and com.google.appengine.api.users.User is of type "injected": so you should not have any problem normally, unless your User is not of this type.

Personaly I have methods like

public Customer insert(final User user, Customer customer, ...

which work perfectly well

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
  • I thought I was supposed to use `import com.google.api.server.spi.auth.common.User;`? see https://github.com/GoogleCloudPlatform/appengine-endpoints-helloworld-java-maven/blob/master/src/main/java/com/example/helloworld/YourFirstAPI.java – Katedral Pillon Oct 25 '16 at 16:57
  • 1
    You can use the two types, according to Google documentation and examples. With com.google.api.server.spi.auth.common.User however, you can only compile when you have no body in the incoming request, as you experienced. There is an issue on the Google issue register that confirm that https://code.google.com/p/googleappengine/issues/detail?id=13197 and apparently Google is currently analyzing it. Other interesting reading on the subject are http://stackoverflow.com/questions/28445840/how-can-i-pass-custom-information-from-an-app-engine-authenticator-to-the-endpoi and ... – Renaud Tarnec Oct 26 '16 at 14:11
  • http://stackoverflow.com/questions/35351830/how-to-retrieve-custom-user-object-in-gae-endpoints where Google Endpoint developer says that it is a bug. – Renaud Tarnec Oct 26 '16 at 14:12