#189 - Fix legacy file storage

This commit is contained in:
Steven Bazyl 2015-01-09 16:02:40 -08:00
parent 21cd5b27b1
commit 28adb02b60
2 changed files with 10 additions and 13 deletions

View File

@ -29,12 +29,10 @@ module Google
#
class FileStorage
attr_accessor :storage,
:path
attr_accessor :storage
def initialize(path)
@path = path
store = Google::APIClient::FileStore.new(@path)
store = Google::APIClient::FileStore.new(path)
@storage = Google::APIClient::Storage.new(store)
@storage.authorize
end
@ -54,8 +52,7 @@ module Google
# Optional authorization instance. If not provided, the authorization
# already associated with this instance will be written.
def write_credentials(auth=nil)
self.authorization = auth unless auth.nil?
storage.write_credentials(self.authorization)
storage.write_credentials(auth)
end
end
end

View File

@ -32,12 +32,12 @@ module Google
# client.authorization = flow.authorize
#
class InstalledAppFlow
RESPONSE_BODY = <<-HTML
<html>
<head>
<script>
function closeWindow() {
function closeWindow() {
window.open('', '_self', '');
window.close();
}
@ -47,14 +47,14 @@ module Google
<body>You may close this window.</body>
</html>
HTML
##
# Configure the flow
#
# @param [Hash] options The configuration parameters for the client.
# @option options [Fixnum] :port
# Port to run the embedded server on. Defaults to 9292
# @option options [String] :client_id
# @option options [String] :client_id
# A unique identifier issued to the client to identify itself to the
# authorization server.
# @option options [String] :client_secret
@ -73,11 +73,11 @@ module Google
:redirect_uri => "http://localhost:#{@port}/"}.update(options)
)
end
##
# Request authorization. Opens a browser and waits for response.
#
# @param [Google::APIClient::FileStorage] storage
# @param [Google::APIClient::Storage] storage
# Optional object that responds to :write_credentials, used to serialize
# the OAuth 2 credentials after completing the flow.
#
@ -85,7 +85,7 @@ module Google
# Authorization instance, nil if user cancelled.
def authorize(storage=nil)
auth = @authorization
server = WEBrick::HTTPServer.new(
:Port => @port,
:BindAddress =>"localhost",