我有一个应用引擎应用,使用oauth和rauth,我试图使用Facebook,Twitter和谷歌登录。
当我在本地运行时工作,但在生产中我得到了这个错误,但只有谷歌加,与Facebook工作正常。
('连接已中止。',错误(13,'权限被拒绝')) Traceback(最近一次调用最后一次): 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py" ;,第1535行,致电 rv = self.handle_exception(request,response,e) 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py" ;,第1529行,致电 rv = self.router.dispatch(请求,响应) 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py",第1278行,在default_dispatcher中 return route.handler_adapter(request,response) 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py",第1102行,致电 return handler.dispatch() 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / handler.py",第11行,发送 webapp2.RequestHandler.dispatch(个体经营) 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py" ;,第572行,在发送中 return self.handle_exception(e,self.app.debug) 文件" /base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py" ;,第570行,发送 返回方法(* args,** kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / loginToken.py",第69行,获取 EP = log.getTokenData(代码) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / conect.py",第34行,在getTokenData中 session = self.getSession(conf,code) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / conect.py",第61行,在getSession中 session = conf.get_auth_session(data = self.getData(code),decoder = json.loads) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / service.py",第556行,在get_auth_session中 session = self.get_session(self.get_access_token(method,** kwargs)) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / service.py",第541行,get_access_token r = self.get_raw_access_token(方法,** kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / service.py",第518行,get_raw_access_token ** kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / session.py",第358行,请求中 return super(OAuth2Session,self).request(method,url,** req_kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / requests / sessions.py",第457行,请求中 resp = self.send(prep,** send_kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / requests / sessions.py",第569行,发送 r = adapter.send(request,** kwargs) 文件" / base / data / home / apps / s~app-getwell / login:1.379942143707124638 / code / oauth / rauth / requests / adapters.py",第407行,发送 引发ConnectionError(错误,请求=请求) ConnectionError :('连接已中止。',错误(13,'权限被拒绝')
我启用了结算功能,并且在yaml中添加了ssl库(最新版)
这是我进行oauth调用的代码
class login():
def __init__(self,tipo=tipoConexion.Google, redirect_uri = 'http://map.getwell.care/'):
self.__tipo=tipo
self.config=config.data(redirect_uri)
def getAuthorizationURL(self):
conf=self.getConfig()
params=self.getParams()
url = conf.get_authorize_url(**params)
return url
def getTokenData(self, code):
''' Get the data that i need from the provider '''
conf=self.getConfig()
session = self.getSession(conf,code)
tokenizerConcreto=JsonReader.factory(self.__tipo,session)
email=tokenizerConcreto.getEmail()[0]
urlPic=tokenizerConcreto.getPicture()[0]
logueado=not tokenizerConcreto.getEmail()[1]
return logueado, urlPic, email
def getParams(self):
params=None
if self.__tipo==tipoConexion.Google:
params = self.config.GooglePlusScope
if self.__tipo==tipoConexion.Facebook:
params = self.config.FacebookScope
return params
def getConfig(self):
conf=self.config.googlePlus
if self.__tipo==tipoConexion.Facebook:
conf=self.config.facebook
if self.__tipo==tipoConexion.Twitter:
conf=self.config.twitter
return conf
def getSession(self,conf, code):
session=None
if self.__tipo==tipoConexion.Google:
session=conf.get_auth_session(data=self.getData(code), decoder=json.loads)
else:
session=conf.get_auth_session(data=self.getData(code))
return session
def getData(self,code):
data=None
if self.__tipo==tipoConexion.Google:
data={
'code' : code,
'redirect_uri': self.config.redirect_uri,
'grant_type':'authorization_code'
}#
logging.info("GetWell: Data previo al error: %s" % data)
if self.__tipo==tipoConexion.Facebook:
data={
'code' : code,
'redirect_uri': self.config.redirect_uri,
}
if self.__tipo==tipoConexion.Twitter:
raise NotImplementedError
return data
这是我得到秘密密钥时的代码
class tipoConexion():
Google=0
Facebook=1
Twitter=2
class data(object):
def __init__(self, url = 'http://map.getwell.care/'):
self.redirect_uri=url
def getURL(self):
return self.redirect_uri
@property
def twitter(self):
return OAuth1Service(
consumer_key='imnotatwitterman',
consumer_secret='ilovevine',
name='twitter',
access_token_url='https://api.twitter.com/oauth/access_token',
authorize_url='https://api.twitter.com/oauth/authorize',
request_token_url='https://api.twitter.com/oauth/request_token',
base_url='https://api.twitter.com/1/')
@property
def facebook(self):
return OAuth2Service(
client_id='someID',
client_secret='MyDarkSecretInFacebook',
name='facebook',
authorize_url='https://graph.facebook.com/oauth/authorize',
access_token_url='https://graph.facebook.com/oauth/access_token',
base_url='https://graph.facebook.com/')
@property
def FacebookScope(self):
return {
'scope': 'public_profile,email',
'response_type': 'code',
'redirect_uri': self.getURL()
}
@property
def googlePlus(self):
return OAuth2Service(
client_id='ThisCouldBeMyID.apps.googleusercontent.com',
client_secret='Idonthaveanysecrets',
name='googlePlus',
authorize_url='https://accounts.google.com/o/oauth2/auth',
access_token_url='https://accounts.google.com/o/oauth2/token',
base_url='https://accounts.google.com/o/oauth2/auth')
@property
def GooglePlusScope(self):
return {
'scope': 'https://www.googleapis.com/auth/plus.profile.emails.read',
'response_type': 'code',
'redirect_uri': self.getURL()
}
正如我所说,最奇怪的是,与Facebook工作正常,但是,谷歌加上失败(我检查client_id和client_secret并且是正确的)如果它是插座的问题,facebook也必须失败< / p>
PS。 我复制项目中的rauth文件和rauth文件夹中的请求文件