我正在學習如何爲Google App引擎創建API後端。 作爲我學習的一部分,我已經成功地實施了以下教程爲Google App Engine API後端添加OAuth失敗
https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/write_api https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/write_api_post
但是,當我試圖添加的OAuth在本教程中所描述的, https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/auth
我收到以下錯誤(期間MVN應用程序引擎:更新)
[ERROR] /Users/raj/Documents/workspace/rajmaven/helloendpoints/src/main/java/com/google/devrel/samples/helloendpoints/Greetings.java:[18,14] error: cannot find symbol [ERROR] symbol: variable Constant
我無法找到錯誤背後的確切原因。有人可以幫助我解決這個問題。
1 package com.google.devrel.samples.helloendpoints;
2
3 import com.google.api.server.spi.config.Api;
4 import javax.inject.Named;
5 import java.util.ArrayList;
6 import com.google.api.server.spi.config.ApiMethod;
7 import com.google.appengine.api.users.User;
8
9 /**
10 * Defines v1 of a helloworld API, which provides simple "greeting" methods.
11 */
12 /*@Api(name = "helloworld", version = "v1") */
13
14
15 @Api(
16 name = "helloworld",
17 version = "v1",
18 scopes = {Constants.EMAIL_SCOPE},
19 clientIds = {com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID}
20)
21 public class Greetings {
22 public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();
23
24 static {
25 greetings.add(new HelloGreeting("hello world!"));
26 greetings.add(new HelloGreeting("goodbye world!"));
27 }
28
29 public HelloGreeting getGreeting(@Named("id") Integer id) {
30 return greetings.get(id);
31 }
32
33 @ApiMethod(name = "greetings.authed", path = "greeting/authed")
34 public HelloGreeting authedGreeting(User user) {
35 HelloGreeting response = new HelloGreeting("hello " + user.getEmail());
36 return response;
37 }
38
39
40 @ApiMethod(name = "greetings.multiply", httpMethod = "post")
41 public HelloGreeting insertGreeting(@Named("times") Integer times, HelloGreeting greeting) {
42 HelloGreeting response = new HelloGreeting();
43 StringBuilder responseBuilder = new StringBuilder();
44 for (int i = 0; i < times; i++) {
45 responseBuilder.append(greeting.getMessage());
46 }
47 response.setMessage(responseBuilder.toString());
48 return response;
49 }
50
51
52 }