Oauth 2.0 deploy web 到google cloud上

princesshan 2017-08-16 04:18:09
目前正在学习python遇到一个问题,是书上的例子
用Google App Engine Launcher 向google上传deploy的时候报错。
deploy的时候出现一个对话框,我输入的google用户名,密码,
报错如下:

Error 404: --- begin server output ---
https://developers.google.com/accounts/docs/AuthForInstalledApps
--- end server output ---
2017-08-16 16:09:26 (Process exited with code 1)

上网查了一下,看到网上好多说需要用Oauth 2.0, 但是这个东西怎么用那?请高手指点一下。

我把代码贴上来。

hfwwgDB.py

from google.appengine.ext import db

_FINS = ['Falcate', 'Triangular', 'Rounded']
_WHALES = ['Humpback', 'Orca', 'Blue', 'Killer', 'Beluga', 'Fin', 'Gray', 'Sperm']
_BLOWS = ['Tall', 'Bushy', 'Dense']
_WAVES = ['Flat', 'Small', 'Moderate', 'Large', 'Breaking', 'High']

class Sighting(db.Model):
name = db.StringProperty()
email = db.StringProperty()
date = db.StringProperty()
time = db.StringProperty()
location = db.StringProperty(multiline=True)
fin_type = db.StringProperty(choices=_FINS)
whale_type = db.StringProperty(choices=_WHALES)
blow_type = db.StringProperty(choices=_BLOWS)
wave_type = db.StringProperty(choices=_WAVES)
which_user = db.UserProperty()


hfwwg.py

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.ext.db import djangoforms
from google.appengine.api import users
import hfwwgDB
class SightingForm(djangoforms.ModelForm):
class Meta:
model = hfwwgDB.Sighting()
exclude = ['which_user']
class SightingInputPage(webapp.RequestHandler):
def get(self):
html = template.render('templates/header.html',{'title':'Report a Possible Sighting'})
html = html + template.render('templates/form_start.html',{})
html = html+ str(SightingForm())
html = html + template.render('templates/form_end.html',{'sub_title':'submitsighting'})
html = html + template.render('templates/footer.html', {'links':''})
self.response.out.write(html)

def post(self):
model = hfwwgDB.Sighting()
model.name = self.request.get('name')
model.email = self.request.get('email')
model.date = self.request.get('date')
model.time = self.request.get('time')
model.location = self.request.get('location')
model.fin_type = self.request.get('fin_type')
model.whale_type = self.request.get('whale_type')
model.blow_type = self.request.get('blow_type')
model.wave_type = self.request.get('wave_type')
model.which_user = users.get_current_user()


model.put()

html = template.render('templates/header.html', {'title': 'Thank you!'})
html = html + "<p>Thank you for providing your sighting data.</p>"
html = html + template.render('templates/footer.html',{'links': 'Enter <a href="/">another sighting</a>.'})

self.response.out.write(html)

app = webapp.WSGIApplication([('/.*', SightingInputPage)], debug= True)
def main():
run_wsgi_app(app)

if __name__=='__main__':
main()


以上代码在本地可以正常运行。
请问如果用Oauth 2.0 , 代码需要做什么修改吗?
或者我需要安装什么吗?应该怎么样上传那?
...全文
92 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,717

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧