我开始使用带有Java的Google App Engine,以及使用带有OAuth 2.0的Google Cloud Endpoints。我有一个简单的端点正常工作,但只在部署时。当我在本地计算机上运行它时出现此错误:
Mar 10, 2014 4:38:54 PM com.google.api.server.spi.WebApisUserService getCurrentUser
INFO: getCurrentUser: AccessToken; scope not allowed
这是我的端点代码:
@Api(
name = "sd",
version = "v1",
scopes = { Constants.EMAIL_SCOPE },
clientIds = { Constants.WEB_CLIENT_ID, Constants.API_EXPLORER_CLIENT_ID })
public class Feeds {
public Feed sample(User user) {
if (user == null) {
return new Feed("Public Feed.");
} else {
return new Feed("Feed for " + user.getEmail());
}
}
}
...
public class Constants {
public static final String WEB_CLIENT_ID = "<snip>.apps.googleusercontent.com";
public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
public static final String API_EXPLORER_CLIENT_ID = com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID;
}
正如我所说,当我部署它并通过API Explorer完全访问它时。当我打开OAuth时,它会返回Feed for <my email address>
,当我将其关闭时,它会返回Public Feed.
但是,当针对我的本地计算机运行时,它始终返回Public Feed.
当OAuth切换打开时,它会将粘贴在此帖子顶部的错误打印到服务器的控制台。我使用网址https://<app_id>.appspot.com/_ah/api/explorer
和http://localhost:8888/_ah/api/explorer
访问了两个api资源管理器。
有人可以帮忙吗?