Exemplo n.º 1
0
 def test_saves_token_to_filesystem(self):
     directory = tempfile.mkdtemp()
     store = FileTokenStore(directory)
     token = YahooToken('some-token', 'some-secret')
     store.set('foo', token)
     with open(store.get_filepath('foo')) as stored_file:
         self.assertTrue('some-token' in stored_file.read())
Exemplo n.º 2
0
    def set(self, name, token):
        """Write a token to file"""

        if hasattr(token, 'key'):
            token = YahooToken.to_string(token)

        if token:
            filepath = self.get_filepath(name)
            f_handle = open(filepath, 'w')
            f_handle.write(token)
            f_handle.close()
Exemplo n.º 3
0
    def set(self, name, token):
        """Write a token to file"""

        if hasattr(token, 'key'):
            token = YahooToken.to_string(token)

        if token:
            filepath = self.get_filepath(name)
            f_handle = open(filepath, 'w')
            f_handle.write(token)
            f_handle.close()
Exemplo n.º 4
0
    def get(self, name):
        """Get a token from the filesystem"""

        filepath = self.get_filepath(name)

        if os.path.exists(filepath):
            f_handle = open(filepath, 'r')
            token = f_handle.read()
            f_handle.close()

            token = YahooToken.from_string(token)
            return token
Exemplo n.º 5
0
    def get(self, name):
        """Get a token from the filesystem"""

        filepath = self.get_filepath(name)

        if os.path.exists(filepath):
            f_handle = open(filepath, 'r')
            token = f_handle.read()
            f_handle.close()

            token = YahooToken.from_string(token)
            return token