def _get_token(self):
        """Get token from JanRain."""
        # HTTP request
        try:
            raw_res = yield from self._session.get(TOKEN_URL,
                                                   headers=self._headers,
                                                   timeout=self._timeout)
        except OSError:
            raise PyFidoError("Can not get token")
        # Research for json in answer
        content = yield from raw_res.text()
        reg_res = re.search(r"\({.*}\)", content)
        if reg_res is None:
            raise PyFidoError("Can not finf token json")
        # Load data as json
        return_data = json.loads(reg_res.group()[1:-1])
        # Get token and uuid
        token = return_data.get('result', {}).get('accessToken')
        uuid = return_data.get('result', {}).get('userData', {}).get('uuid')
        # Check values
        if token is None or uuid is None:
            raise PyFidoError("Can not get token or uuid")

        return token, uuid
def _get_token ( self ) : try : raw_res = yield from self . _session . get ( TOKEN_URL , headers = self . _headers , timeout = self . _timeout ) except OSError : raise PyFidoError ( "Can not get token" ) content = yield from raw_res . text ( ) reg_res = re . search ( r"\({.*}\)" , content ) if reg_res is None : raise PyFidoError ( "Can not finf token json" ) return_data = json . loads ( reg_res . group ( ) [ 1 : - 1 ] ) token = return_data . get ( 'result' , { } ) . get ( 'accessToken' ) uuid = return_data . get ( 'result' , { } ) . get ( 'userData' , { } ) . get ( 'uuid' ) if token is None or uuid is None : raise PyFidoError ( "Can not get token or uuid" ) return token , uuid
Get token from JanRain.