Finish adding Storage to the OAuth 1.0 client and updated all examples to use file.Storage. No more three_legged_dance.py files anywhere.
diff --git a/apiclient/ext/authtools.py b/apiclient/ext/authtools.py
index f605d72..c383811 100644
--- a/apiclient/ext/authtools.py
+++ b/apiclient/ext/authtools.py
@@ -76,12 +76,21 @@
pass
-def run(flow, filename):
+def run(flow, storage):
"""Core code for a command-line application.
+
+ Args:
+ flow: Flow, an OAuth 1.0 Flow to step through.
+ storage: Storage, a Storage to store the credential in.
+
+ Returns:
+ Credentials, the obtained credential.
+
+ Exceptions:
+ RequestError: if step2 of the flow fails.
+ Args:
"""
parser = OptionParser()
- parser.add_option("-f", "--file", dest="filename",
- default=filename, help="write credentials to FILE", metavar="FILE")
parser.add_option("-p", "--no_local_web_server", dest="localhost",
action="store_false",
default=True,
@@ -134,9 +143,8 @@
except RequestError:
sys.exit('The authentication has failed.')
- f = open(filename, 'w')
- f.write(pickle.dumps(credentials))
- f.close()
+ storage.put(credentials)
+ credentials.set_store(storage.put)
print "You have successfully authenticated."
return credentials
diff --git a/apiclient/ext/file.py b/apiclient/ext/file.py
index 0a2c97c..dba723e 100644
--- a/apiclient/ext/file.py
+++ b/apiclient/ext/file.py
@@ -28,9 +28,9 @@
f = open(self._filename, 'r')
credentials = pickle.loads(f.read())
f.close()
+ credentials.set_store(self.put)
except:
credentials = None
- credentials.set_store(self.put)
return credentials