When I try to upload a sample csv data to my GAE app through appcfg.py
, it shows the below 401 error.
2015-11-04 10:44:41,820 INFO client.py:571 Refreshing due to a 401 (attempt 2/2)
2015-11-04 10:44:41,821 INFO client.py:797 Refreshing access_token
Error 401: --- begin server output ---
You must be logged in as an administrator to access this.
--- end server output ---
Here is the command I tried,
appcfg.py upload_data --application=dev~app --url=http://localhost:8080/_ah/remote_api --filename=data/sample.csv
Maybe this has something to do with it? From the docs
Link to Docs
https://cloud.google.com/datastore/docs/tools/devserver
I had a similar issue, where
appcfg.py
was not giving me any credentials dialog, so I could not authenticate. I downgraded from GAELauncher 1.27 to 1.26, and the authentication started working again.Temporary solution: go to https://console.developers.google.com/storage/browser/appengine-sdks/featured/ to get version 1.9.26
Submitted bug report: https://code.google.com/p/google-cloud-sdk/issues/detail?id=340
This is how we do it in order to use custom authentication.
Custom handler in app.yaml
Custom wsgi app in remote_api.py to override
CheckIsAdmin
From here we script the uploading of data that was exported from our live app. Use the same password that you made up in the python script above.
WebHook
andwebhook.data
are specific to theKind
that we exported from production.You cannot use the
appcfg.py upload_data
command with the development server [edit: as is; see Josh J's answer]. It only works with theremote_api
endpoint running on App Engine and authenticated with OAuth2.An easy way to load data into the dev server's datastore is to create an endpoint that reads a CSV file and creates the appropriate datastore entities, then hit it with the browser. (Be sure to remove the endpoint before deploying the app, or restrict access to the URL with
login: admin
.)You must have an oauth token for a google account that is not an admin of that project. Try passing the
--no_cookies
flag so that it prompts for authentication again.