Which credentials should I put in for Google App E

2019-03-21 03:02发布

I would like to ask which kind of credentials do I need to put on for importing data using the Google App Engine BulkLoader class

appcfg.py upload_data --config_file=models.py --filename=listcountries.csv --kind=CMSCountry --url=http://localhost:8178/remote_api vit/

And then it asks me for credentials:

Please enter login credentials for localhost

Here is an extraction of the content of the models.py, I use this listcountries.csv file

class CMSCountry(db.Model):
  sortorder = db.StringProperty()
  name = db.StringProperty(required=True)
  formalname = db.StringProperty()
  type = db.StringProperty()
  subtype = db.StringProperty()
  sovereignt = db.StringProperty()
  capital = db.StringProperty()
  currencycode = db.StringProperty()
  currencyname = db.StringProperty()
  telephonecode = db.StringProperty()
  lettercode = db.StringProperty()
  lettercode2 = db.StringProperty()
  number = db.StringProperty()
  countrycode = db.StringProperty()

class CMSCountryLoader(bulkloader.Loader):
  def __init__(self):
    bulkloader.Loader.__init__(self, 'CMSCountry',
                           [('sortorder', str),
                            ('name', str),
                            ('formalname', str),
                            ('type', str),
                            ('subtype', str),
                            ('sovereignt', str),
                            ('capital', str),
                            ('currencycode', str),
                            ('currencyname', str),
                            ('telephonecode', str),
                            ('lettercode', str),
                            ('lettercode2', str),
                            ('number', str),
                            ('countrycode', str)
                            ])
loaders = [CMSCountryLoader] 

Every tries to enter the email and password result in "Authentication Failed", so I could not import the data to the development server.

I don't think that I have any problem with my files neither my models because I have successfully uploaded the data to the appspot.com application.
So what should I put in for localhost credentials?
I also tried to use Eclipse with Pydev but I still got the same message :(
Here is the output:

Uploading data records.
[INFO    ] Logging to bulkloader-log-20090820.121659
[INFO    ] Opening database: bulkloader-progress-20090820.121659.sql3
[INFO    ] [Thread-1] WorkerThread: started
[INFO    ] [Thread-2] WorkerThread: started
[INFO    ] [Thread-3] WorkerThread: started
[INFO    ] [Thread-4] WorkerThread: started
[INFO    ] [Thread-5] WorkerThread: started
[INFO    ] [Thread-6] WorkerThread: started
[INFO    ] [Thread-7] WorkerThread: started
[INFO    ] [Thread-8] WorkerThread: started
[INFO    ] [Thread-9] WorkerThread: started
[INFO    ] [Thread-10] WorkerThread: started
Password for foobar@nowhere.com: [DEBUG   ] Configuring remote_api. url_path = /remote_api, servername = localhost:8178

[DEBUG   ] Bulkloader using app_id: abc
[INFO    ] Connecting to /remote_api
[ERROR   ] Exception during authentication
Traceback (most recent call last):
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\bulkloader.py", line 2802, in Run
request_manager.Authenticate()
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\bulkloader.py", line 1126, in Authenticate
remote_api_stub.MaybeInvokeAuthentication()
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 488, in MaybeInvokeAuthentication
datastore_stub._server.Send(datastore_stub._path, payload=None)
  File "D:\Projects\GoogleAppEngine\google_appengine\google\appengine\tools\appengine_rpc.py", line 344, in Send
f = self.opener.open(req)
  File "C:\Python25\lib\urllib2.py", line 381, in open
response = self._open(req, data)
  File "C:\Python25\lib\urllib2.py", line 399, in _open
'_open', req)
  File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 1107, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python25\lib\urllib2.py", line 1082, in do_open
raise URLError(err)
URLError: <urlopen error (10061, 'Connection refused')>
[INFO    ] Authentication Failed

Thank you!

9条回答
做个烂人
2楼-- · 2019-03-21 03:30

Edit: Look at my new solution

This problem is still present. I have opened a ticket to ask if the authentication could be bypassed on the local dev server. Please vote for this issue so that we can have it resolved [quickly].

I have been able to upload data to the dev server by:

  • leaving the "login:admin" line in app.yaml
  • adding "--email=foobar@nowhere.com" to your command
  • pressing Enter when prompted for a password (nothing required)

Leaving the "login:admin" line is a good thing, as you will not upload your app on the production servers without this line, which could expose you to someone adding data to your datastore...

Blockquote

查看更多
smile是对你的礼貌
3楼-- · 2019-03-21 03:31

You need create an admin credential in your local development server first.

With your firefox (or chrome safari etc), open http://localhost:8178/remote_api, you will be asked to login (without password), enter an email as your login, and tick the login as administrater box, login. This will create you a local admin credential for you, use this when bulkloading locally.

It applies to other admin required local access.

Leaving (or commenting) out login:admin is a bad practice, since you might deploy that into production, too. Take care!

查看更多
甜甜的少女心
4楼-- · 2019-03-21 03:33

I use this commands to transfer data from local to remote server. File's extension (json) is important. Framework: django-nonrel, os: Win7.

manage.py dumpdata >dump.json
manage.py remote loaddata dump.json
查看更多
趁早两清
5楼-- · 2019-03-21 03:35

Another solution is to stub out the auth function with lambda: http://www.carlosble.com/?p=603

查看更多
老娘就宠你
6楼-- · 2019-03-21 03:36

Use aaa@gmail.com for username.

Use a for password.

It works. Magically.

查看更多
一纸荒年 Trace。
7楼-- · 2019-03-21 03:38

Next worked for me:

  • removing the line

    login:admin
    

    from app.yaml

  • Updating app cofig:

    appcfg.py update [app-id]
    
  • (Re)starting local server:

    appserver [app-id] 
    
  • Upload data:

    appcfg.py upload_data --config_file=album_loader.py --filename album_data.csv --kind Album --url=http://localhost:8080/remote_api ../[app-id] 
    

    Ask for mail and password type anything

查看更多
登录 后发表回答