Exemplo n.º 1
0
 def fake_get_auth_header(self, oauth_params, realm=None):
     auth_header = 'OAuth realm="{realm}"'.format(realm=realm)
     params = ''
     for k, v in iteritems(oauth_params):
         params += ',{key}="{value}"'.format(key=k, value=quote(str(v)))
     auth_header += params
     return auth_header
Exemplo n.º 2
0
 def _get_auth_header(self, oauth_params, realm=None):
     '''Constructs and returns an authentication header.'''
     auth_header = 'OAuth realm="{realm}"'.format(realm=realm or '')
     params = ''
     for k, v in oauth_params.items():
         params += ',{key}="{value}"'.format(key=k, value=quote(str(v)))
     auth_header += params
     return auth_header
Exemplo n.º 3
0
    def _escape(self, s):
        '''
        Escapes a string, ensuring it is encoded as a UTF-8 octet.

        :param s: A string to be encoded.
        :type s: str
        '''
        return quote(self._ensure_unicode(s), safe='~').encode('utf-8')
Exemplo n.º 4
0
 def _get_auth_header(self):
     ''' Constructs and returns an authentication header. '''
     realm = 'realm="{realm}"'.format(realm=self.realm)
     params = [
         '{k}="{v}"'.format(k=k, v=quote(str(v)))
         for k, v in self.oauth_params.items()
     ]
     return 'OAuth ' + ','.join([realm] + params)