硬编码密码到谷歌应用程序引擎启动器与文本文件

时间:2014-08-29 03:29:34

标签: python google-app-engine

在谷歌应用引擎启动器中为每个部署重新输入密码浪费了很多时间。有没有办法我可以用文本文件硬编码电子邮件和密码?我尝试编辑appcfg.py但没有用。我理解这种方法所涉及的风险,但我仍然想知道。

3 个答案:

答案 0 :(得分:1)

请考虑使用--oauth2 param。这可能不适用于应用引擎启动器,但如果您要为部署创建自定义bash脚本,它将无法正常工作。您可以在this页面上阅读更多内容。

  

如果您不想输入登录凭据,可以使用   改为使用OAuth2令牌。此令牌可以访问App Engine,但不能访问   到您的Google帐户的其他部分;如果您的Google帐户使用   双因素身份验证,你会发现这特别方便。您   可以存储此令牌以永久登录此计算机。

如果您是Sublime Text用户,可以将此代码添加到项目配置文件中,以便能够使用CMD + B或CTRL + B等热键进行部署。我确信对于大多数主要代码编辑器来说,这很容易。

{
  "build_systems":
  [
    {
      "name": "App Engine Deploy",
      "cmd": ["cd $project_path; appcfg.py --oauth2 update ."],
      "shell": true
    }
  ]
}

答案 1 :(得分:0)

你不能直接硬编码密码,但我做了这个技巧,将密码附加到电子邮件参数,以便在蝙蝠文件中硬编码密码

1。您必须备份YOURAPPENGINEURL / google / appengine / tools / appcfg.py。 然后在该文件中查找以下代码块

  def GetUserCredentials():
  """Prompts the user for a username and password."""
  email = self.options.email
  if email is None:
    email = self.raw_input_fn('Email: ')

  password_prompt = 'Password for %s: ' % email


  if self.options.passin:
    password = self.raw_input_fn(password_prompt)
  else:
    password = self.password_input_fn(password_prompt)

  return (email, password)

此代码在运行时解析电子邮件和提示密码。

2。将此代码块替换为以下代码块

  def GetUserCredentials():
  """Prompts the user for a username and password."""
  email = self.options.email
  if email is None:
    email = self.raw_input_fn('Email: ')

  tmp=email.split(':')
  email=tmp[0]
  password=tmp[1]

  return (email, password)

然后保存您的appcfg文件。

3。现在您可以使用以下命令对密码进行硬编码

 appcfg.py --no_cookies --email=youremail@gmail.com:YOURPASSWORD update ./

4. 重要的是,您只能通过在电子邮件中附加密码来更新您的应用。 app.cfg永远不会提示输入密码

答案 2 :(得分:-1)

我决定和第三方一起讨论这个问题;利用“自动”:

感谢Matt这个

Local $sLauncherPath = "C:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe"
Local $iPid = Run($sLauncherPath)

Local $hWin
While ProcessExists($iPid)
$hWin = WinWait("Deploy Application to Google", "", 1)

If $hWin And WinGetProcess($hWin) = $iPid Then
    ControlSetText($hWin, "", "Edit1", "MyEmail@Domain.com")
    ControlSetText($hWin, "", "Edit2", "MyPassword123")

    ControlClick($hWin, "", "Button2")

    WinWaitClose($hWin)
EndIf
WEnd
相关问题