Can not download code from google app engine - google-app-engine

I want to download the code from google app engine.
And I installed python, google engine sdk and executed this command
appcfg.py download_app -a ...
and I typed my mail address and password...
but it says
Error 403: ---
You do not have permission to download this app version
What do you think is the problem? Please help me with this.
I am stuck with this like all day but can't find the solution.

I encountered the same problem (Mac OS, running AppEngineLauncher).
Noticed that no apps were running in GAEL.
Running one of the apps in GAEL (earlier version of the same one - could be a coincidence) seemed to make a difference - it started the download, but then halted.
Then I ran appcfg list_versions on that app, followed by download_app.
That seemed to do the job - download continuing as I write this.
On a guess, appcfg got hazy about its security context. YMMV.

Check:
Only the developer who uploaded the code and the application owner(s) can download it. If anyone other than these parties attempts to download the app, they'll see an error message like the following: Error 403
https://developers.google.com/appengine/docs/python/tools/uploadinganapp#Python_Downloading_source_code
or your app have set permanently prohibit code downloads. Check on page: https://appengine.google.com/deployment/codelock?app_id=your_app_id&to_forward=/permissions?app_id=your_app_id

Adding flag --no_cookies worked for me.

Related

Google App Engine: connection interrupted while running gradle appengineDeploy and now application will not work (including firebase cloud messaging)

While I was deploying my google app engine project (Java) using gradle appengineDeploy my internet connection was interrupted.
I re-deployed the project. Although the console said BUILD SUCCESSFUL, the app engine instance no longer works. No matter how many times I re-deploy or update my application, the logs show nothing but errors:
java.lang.NoClassDefFoundError: com/google/appengine/api/ThreadManager
at
com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter.createClient
(GoogleAppEngineControlFilter.java:61) at
com.google.api.control.ControlFilter.init (ControlFilter.java:141) at
org.eclipse.jetty.servlet.FilterHolder.initialize
(FilterHolder.java:139) at
org.eclipse.jetty.servlet.ServletHandler.initialize
(ServletHandler.java:873) at
org.eclipse.jetty.servlet.ServletContextHandler.startContext
(ServletContextHandler.java:349) at
org.eclipse.jetty.webapp.WebAppContext.startWebapp
(WebAppContext.java:1406) at
com.google.apphosting.runtime.jetty9.AppEngineWebAppContext.startWebapp
(AppEngineWebAppContext.java:175) at
org.eclipse.jetty.webapp.WebAppContext.startContext
(WebAppContext.java:1368) at
org.eclipse.jetty.server.handler.ContextHandler.doStart
(ContextHandler.java:778) at
org.eclipse.jetty.servlet.ServletContextHandler.doStart
(ServletContextHandler.java:262) at
org.eclipse.jetty.webapp.WebAppContext.doStart
(WebAppContext.java:522) at
com.google.apphosting.runtime.jetty9.AppEngineWebAppContext.doStart
(AppEngineWebAppContext.java:120) at
org.eclipse.jetty.util.component.AbstractLifeCycle.start
(AbstractLifeCycle.java:68) at
com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler
(AppVersionHandlerMap.java:240) at
com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler
(AppVersionHandlerMap.java:178) at
com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest
(JettyServletEngineAdapter.java:120) at
com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest
(JavaRuntime.java:747) at
com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest
(JavaRuntime.java:710) at
com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run
(JavaRuntime.java:680) at
com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run
(JavaRuntime.java:872) at
com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run
(ThreadGroupPool.java:270) at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.ClassNotFoundException:
com.google.appengine.api.ThreadManager at
java.net.URLClassLoader.findClass (URLClassLoader.java:381) at
com.google.apphosting.runtime.ApplicationClassLoader.findClass
(ApplicationClassLoader.java:135) at java.lang.ClassLoader.loadClass
(ClassLoader.java:424) at java.lang.ClassLoader.loadClass
(ClassLoader.java:357)
Is there some way for me to clear out the partial build (or whatever there may be) in google app engine?
I tried deleting all versions and instances (you cannot delete them all, it won't let you delete the serving one).
I tried increasing the version number in appengine-web.xml.
I tried gradle clean.
I tried disabling and enabling the application in the google cloud console.
No luck.
One idea I have is maybe if I can somehow force all the files for the app to be uploaded again? Because with gradle appengineDeploy only the changed files get uploaded.
EDIT:
I managed to fix one part of this by upgrading classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0' in my gradle to the latest version. (Felt kind of hackish to do that and not reliable in the future if this happens again.) Maybe this flushed whatever was in app engine or something by doing that. I still have one problem remaining:
I am using the firebase admin SDK to send firebase cloud messages (authenticated with a .json credentials file) like this:
FirebaseMessaging.getInstance().send(msg);
When I do I am getting this error:
com.google.firebase.messaging.FirebaseMessagingException: Unexpected
HTTP response with status: 401; body: null
Which is strange because other parts of the firebase admin SDK are working (like writing/reading from firestore).
So there is still something weird going on and I think it has to do with the fact that as I was uploading my google app engine project the connection was interrupted.
EDIT 2:
Here is something interesting: When I deploy my application using gcloud app deploy appengine-web.xml the application again will not work. Deploying with gradle appengineDeploy does though. I also noticed that the size of the application is shown as much smaller in the GCP console when deploying with gcloud app deploy appengine-web.xml. So something is messed up here. I tried looking up some sort of gcloud command to clear cache? Or something like that but no luck.
EDIT 3:
Additional Info:
My app was already deployed and working before the failed attempt. I changed one small piece of code in a function and upon uploading the app, the connection was interrupted because the internet went out.
I am on app engine standard environment.
I am deploying my application from the macOS terminal and using android studio to develop.
I have tried the stopPreviousVersion promote and version configs in gradle (actually the first two are true by default and version gets auto-generated if you do not set it).
Running gcloud app deploy appengine-web.xml --verbosity=debug shows a lot of sensitive information but one thing I am seeing is all the files in WEB-INF are being skipped:
DEBUG: Skipping upload of [WEB-INF/....
INFO: Incremental upload skipped 100.0% of data
DEBUG: Uploading 0 files to Google Cloud Storage
DEBUG: Using [16] threads
So perhaps files are not all being uploaded? This SO post raises a similar problem but has no solution: stackoverflow.com/q/42137452/3075340
It's weird but when I do gcloud app deploy, the app won't work at all. There are run-time errors all over the place. Doing gradle appengineDeploy fixes that but I still am having the firebase-admin issue.
To actually answer your question, GAE uses a staging bucket to cache files.
You can delete this bucket, and it will get recreated next time you try to deploy.
The bucket is always named staging.[PROJECT-ID].appspot.com. It should show on the buckets overview page
Just to be clear, I'm not anywhere near sure that this will actually resolve your issue, but this will most definitely clear whatever files GAE cached
Here there was a discussion on a, more or less, similar issue on App Engine from last year.
You can use it as a source of inspiration to fix your current issue, because I think they are really similar as a concept. From there I think it may worth trying to put the appengine-api-1.0-sdk-1.9.63.jar ( or whatever your version is ) file under WEB-INF/lib.
It the same post there were some guys who found out the there was a problem with gcloud v194 and switching to another version fixed the issue.
Here there is a similar issue which was resolved by upgrading the gcloud tool.
Anyhow, this behaviour is not normal and things should not work like this. You can try to find a workaround, but my recommendation is to report the issue and let an App Engine engineer taking a look over it. There are good chances to be something internal.

Using go delve with google app engine standard & dev_appserver.py

In the google release notes it says:
November 15, 2017
Go runtime notes
Updated Go SDK to 1.9.61
Add --go_debugging flag to dev_appserver.py to enable Delve debugging.
I'm using dev_appserver.py to fire up several services simultaneously, so that they all share the same datastore emulator, and it works great.
However, when I add that --go_debugging flag, I get lots of errors which I don't understand. If anyone has insight, I'd be grateful.
I get these kinds of errors for each service it tries to build:
can't load package: package -N: unknown import path "-N": cannot find module providing package -N
can't load package: package -l: unknown import path "-l": cannot find module providing package -l
Is there maybe a problem with launching several services at once?
Thanks!
Update Nov 2020:
With all the new changes to app engine being able to use standard go libraries at google APIs, now I can just run my go app locally without using dev_appserver, and let it attach to my local datastore emulator etc. Because of that, and thanks to vscode, delve debugging works great (with the go extension). So now I can step through my app engine standard go code.

How do I clone a website that is hosted on Google App Engine?

I have a friend's website hosted on Google App Engine and he wants a some changes to be done. He wants to download the assets from there and build it from scratch into a different host provider. Thing is, when I enter in the Google App Engine Dashboard I find it so hard to export/download anything. All looks so messy. I can't even find the index.html and css files. Any answers would be really appreciated. Thanks.
You can download an application's source code by running appcfg.py with the download_app action in the Python SDK command-line tool:
appcfg.py download_app -A <your_app_id> -V <your_app_version> <output-dir>
Only the developer who uploaded the code and the application owner(s) can download it. But you can be added as admin by the current account holder and then your credentials will work on the command line.
It's possible downloading of source-code has been permanently disabled. This action is irreversible. After you prohibit code download, there is no way to re-enable this feature.
See this page for more: Python Downloading source code
Instructions above for python version. For Java look here. Others, start here.

My Google App Engine appspot URL wont work

I recently created my Google App Engine account, and uploaded my application, and have an instance of said app running.
I can access my app via localhost:8080 but when I try to use myappid.appspot.com I get a 500 Server Error (Of course I replace "myappid" with my apps name). This is what it says:
"Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it."
Can anyone help me get the URL working? I need my team to be able to access this app from anywhere. I have no idea what could be wrong with it, I am very new to GAE. After a lot of searching all I find is people saying their appspot URL works, and want other options. But I just want my appspot URL to work first!
Some more info:
This is a Python app, using the GAE Python SDK, I am running Windows 7, and using the GAE Launcher GUI to deploy and run the app.
Thanks in advance!
EDIT: Here is the error in my Log:
: No module named flask Traceback (most recent call last): File "/base/data/home/apps/s~luxtestapp/1.362824400913245138/bootstrap.py", line 19, in from app import create_app File "/base/data/home/apps/s~luxtestapp/1.362824400913245138/app/init.py", line 10, in from flask import Flask
Apparently the app uses Flask instead of Webbapp2. Honestly I'm not too sure about it all, because this is a pre-built app that I downloaded and deployed. I didn't write it.
In the control panel for your app on appspot go to the log section.
Appengine
The see what the latest entry says. Filter to "error".
Also when you create your app (python webapp2 example) turn debugging on:
app = webapp2.WSGIApplication([
('/', MainHandler)],
debug=True)
You'll get a much more informative error screen then instead of '500'.
You need to copy the flask folder to your project folder. In general every package not supported by GAE (see list of supported libraries), must be present in the project folder.
Try setting the environment variables before/after deploy. Go to the local project folder, open bash the paste this commands: ps: Ignore the $ sign
$ set HTTP_PROXY=http://cache.example.com:3128
$ set HTTPS_PROXY=http://cache.example.com:3128
check this link out for help: cloud.google.com/appengine/docs/python/tools/uploadinganapp

Google App Engine Hello World not working (Eclipxse, Java)

I have checked and rechecked to see that I've done everything correctly, fixed a few problems with java 1.7 (set java compliance to 1.6) etc, and ran the program in develop mode and debug mode.
But when I go to the URL given (http://localhost:8888) I get a 404 screen:
HTTP ERROR: 404
Problem accessing /. Reason:
NOT_FOUND
Powered by Jetty://
The welcome file index.html is in the war directory and web.xml lists index.html as the welcome file. I get the same screen when I try to get the admin console at /_ah/admin as well. The logs I could find didn't show anything. Obviously GAE is working as it uses Jetty, any other port number I enter gives me a browser error:
Oops! Google Chrome could not connect to localhost:8887
Suggestions:
Try reloading: localhost:­8887
Search on Google:
So what could be the problem? I checked file and directory permissions but I'm the only user on this computer ... any ideas or help is appreciated.
James
EDIT
I figured out the problem. My browser cache was holding a different package I had installed previously in my workspace. Simply clearing the cache after terminating all launches was the working solution. I was then able to continue with the excellent tutorial.
http://googcloudlabs.appspot.com/whatgae.html
GAE requires a controlled setup and a good place to follow and start is GAE tutorial. Here is a link GAE TUTORIAL
Look at my answer here.
You have to change Java version in Project Facet also.
GAE does not yet support being run with Java 1.7. Setting a compliance mode for Eclipse doesn't have any effect.
And that error you're getting form Eclipse for port :8887 is telling you that no application on your local machine is listening on that port. It provides no evidence one way or the other as to whether GAE is working.
Try again with Java 1.6.

Resources