5

我有一个应用引擎应用程序,使用 oauth 和rauth,我正在尝试使用 Facebook、Twitter 和 google 登录。

当我在本地运行它时,但在生产中我得到了这个错误,但只有 google plus,facebook 工作正常。

('Connection aborted.', error(13, 'Permission denied')) Traceback (最近一次调用最后): File "/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(request, response) 文件 "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py",行1278、在default_dispatcher返回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() File "/base/data/home/apps/s~app-getwell/login:1.379942143707124638/handler.py",第 11 行,在 dispatch webapp2.RequestHandler.dispatch(self) File "/base/ data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py",第 572 行,在 dispatch return self.handle_exception(e, self.app.debug) File "/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(code) 文件“/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 会话中= 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(method, **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 行,在请求中返回 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(err, request =request) ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))379942143707124638/code/oauth/rauth/session.py”,第 358 行,在请求中返回 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(err, request=request) ConnectionError: ('Connection aborted.', error(13, '没有权限'))379942143707124638/code/oauth/rauth/session.py”,第 358 行,在请求中返回 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(err, request=request) ConnectionError: ('Connection aborted.', error(13, '没有权限'))在请求中返回 super(OAuth2Session, self).request(method, url, **req_kwargs) File "/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/ session.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(err, request=request) ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))在请求中返回 super(OAuth2Session, self).request(method, url, **req_kwargs) File "/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/ session.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(err, request=request) ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))/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(err, request=request) ConnectionError: ('连接中止',错误(13,'权限被拒绝'))/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(err, request=request) ConnectionError: ('连接中止',错误(13,'权限被拒绝'))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(err, request=request) ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))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(err, request=request) ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

我启用了计费,并在 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 上正常工作,但是,如果使用 google plus 失败(我会检查 client_id 和 client_secret 并且是正确的),如果套接字有问题,facebook 也必须失败

附言。我复制项目中的 rauth 文件和 rauth 文件夹中的请求文件

4

0 回答 0