1

I'm very familiar with REST services and have just started with Google Endpoints.

I have the following class:

@Api(
  name = "events",
  version = "v1"
)
public class EventEndpoint {

  @ApiMethod(
      name = "events.get.all",
      path = "get",
      httpMethod = HttpMethod.GET
  )
  // http://localhost:8888/_ah/api/events/v1/get
  public List<Event> getEvents() {
    return new EventDao().findAll();
  }
}

which returns the following json:

{
  "items" : [ {
    "id" : "1",
    "version" : 1
  }, {
    "id" : "2",
    "version" : 1
  } ]
}

Now - what I'm wondering is - if I change the Api method to include the following:

@Api(
  ...
  scopes = {"https://www.googleapis.com/auth/userinfo.email"}

and add a User object to my getEvents method, is there any way I can simply access it in the browser as a logged in Google User. Currently when I step through it with a debugger the User object is null.

I'm not (obviously) super familiar with how this works - I plan to put an AngularJS front end on this, get a token like the link here: https://developers.google.com/appengine/docs/java/endpoints/consume_js#adding-oath-authentication, but I'd like to at least be able to test my web services in the browser. Is this currently possible? This may be a simple question I'm just having problems finding out how to do it.

Thank you

4

1 回答 1

2

Use the Google APIs Explorer:

https://your-app-id.appspot.com/_ah/api/explorer

It has Javascript methods that consume the Discovery Document for you application, facilitate the OAuth dance and send your requests based on the parameters and payload schemas that you define for your methods.

于 2013-06-14T02:01:03.217 回答