GAE远程API - 无法连接 [英] GAE Remote API - Cannot connect
问题描述
好的,我尝试连接到远程数据存储失败,并使用以下列出的步骤从我的本地计算机填充: https://cloud.google.com/appengine/docs/java/tools/remoteapi#Configuring_Remote_API_on_the_Client
public static void main(String [] args){
String username =myemail@gmail.com;
String password =mygmailpassword;
RemoteApiOptions选项=新的RemoteApiOptions()
.server(myappname.appspot.com,443)
.credentials(username,password);
RemoteApiInstaller安装程序=新的RemoteApiInstaller();
installer.install(options);
尝试{
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
...
我在installer.install(options)中得到了404:
java.io.IOException:无法从远程api获取appId;状态代码= 404
我在这里错过了什么吗?我在我的web.xml中启用了远程API,并部署到GAE。我是该项目的所有者。
在本地运行您的服务(启用远程API) localhost'和8888(端口),并检查您的代码是否可以访问本地运行的服务。你的代码看起来不错。有两种可能性 -
1. RemoteApi未正确启用。
2. app-name拼写不正确。
除此之外,我还使用以下代码访问远程api-
installer.install(options);
尝试{
//使用可重用凭证更新选项,以便我们可以在随后的调用中跳过
//认证。
options.reuseCredentials(username,installer.serializeCredentials());
} finally {
installer.uninstall();
}
但是,这不应该给你错误。
Ok, I'm attempting unsuccessfully to connect to a remote datastore and populate from my local machine using the steps outlined here: https://cloud.google.com/appengine/docs/java/tools/remoteapi#Configuring_Remote_API_on_the_Client
public static void main(String[] args) {
String username = "myemail@gmail.com";
String password = "mygmailpassword";
RemoteApiOptions options = new RemoteApiOptions()
.server("myappname.appspot.com", 443)
.credentials(username, password);
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
try {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
...
I'm getting a 404 in installer.install(options): java.io.IOException: can't get appId from remote api; status code = 404 Am I missing something here? I enabled the remote api in my web.xml and deployed to GAE. I am the owner of the project.
Run your service locally (with remote api enabled) and try running same code using 'localhost' and 8888 (port) and check if your code can access locally running service. Your code seems right. There are 2 possibilities - 1. RemoteApi is not enabled correctly. 2. app-name is not spelled correctly.
Other than this, I also use following code to access remote api-
installer.install(options);
try {
// Update the options with reusable credentials so we can skip
// authentication on subsequent calls.
options.reuseCredentials(username, installer.serializeCredentials());
} finally {
installer.uninstall();
}
However, that shouldn't give you the error you're getting.
这篇关于GAE远程API - 无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!