Skip to content

Instantly share code, notes, and snippets.

@rominirani
Last active March 7, 2016 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rominirani/9004217 to your computer and use it in GitHub Desktop.
Save rominirani/9004217 to your computer and use it in GitHub Desktop.
@ApiMethod(name = "insertQuote", scopes = {Constants.EMAIL_SCOPE},
clientIds = {Constants.WEB_CLIENT_ID,
Constants.ANDROID_CLIENT_ID,
com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID},
audiences = {Constants.ANDROID_AUDIENCE})
public Quote insertQuote(Quote quote, User user) throws UnauthorizedException {
if (user == null) throw new UnauthorizedException("User is Not Valid");
PersistenceManager mgr = getPersistenceManager();
try {
if (quote.getId() != null) {
if (containsQuote(quote)) {
throw new EntityExistsException("Object already exists");
}
}
mgr.makePersistent(quote);
} finally {
mgr.close();
}
return quote;
}
@boogie4eva
Copy link

Exception handling from google has been updated to OAuthRequestException as mentioned here sir .
Although your technique is much more friendly .
https://cloud.google.com/appengine/docs/java/endpoints/auth
Thanks for the amazing write up its been really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment