#189 - Fix legacy file storage
This commit is contained in:
parent
21cd5b27b1
commit
28adb02b60
|
@ -29,12 +29,10 @@ module Google
|
||||||
#
|
#
|
||||||
class FileStorage
|
class FileStorage
|
||||||
|
|
||||||
attr_accessor :storage,
|
attr_accessor :storage
|
||||||
:path
|
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@path = path
|
store = Google::APIClient::FileStore.new(path)
|
||||||
store = Google::APIClient::FileStore.new(@path)
|
|
||||||
@storage = Google::APIClient::Storage.new(store)
|
@storage = Google::APIClient::Storage.new(store)
|
||||||
@storage.authorize
|
@storage.authorize
|
||||||
end
|
end
|
||||||
|
@ -54,8 +52,7 @@ module Google
|
||||||
# Optional authorization instance. If not provided, the authorization
|
# Optional authorization instance. If not provided, the authorization
|
||||||
# already associated with this instance will be written.
|
# already associated with this instance will be written.
|
||||||
def write_credentials(auth=nil)
|
def write_credentials(auth=nil)
|
||||||
self.authorization = auth unless auth.nil?
|
storage.write_credentials(auth)
|
||||||
storage.write_credentials(self.authorization)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,12 +32,12 @@ module Google
|
||||||
# client.authorization = flow.authorize
|
# client.authorization = flow.authorize
|
||||||
#
|
#
|
||||||
class InstalledAppFlow
|
class InstalledAppFlow
|
||||||
|
|
||||||
RESPONSE_BODY = <<-HTML
|
RESPONSE_BODY = <<-HTML
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
function closeWindow() {
|
function closeWindow() {
|
||||||
window.open('', '_self', '');
|
window.open('', '_self', '');
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
@ -47,14 +47,14 @@ module Google
|
||||||
<body>You may close this window.</body>
|
<body>You may close this window.</body>
|
||||||
</html>
|
</html>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
##
|
##
|
||||||
# Configure the flow
|
# Configure the flow
|
||||||
#
|
#
|
||||||
# @param [Hash] options The configuration parameters for the client.
|
# @param [Hash] options The configuration parameters for the client.
|
||||||
# @option options [Fixnum] :port
|
# @option options [Fixnum] :port
|
||||||
# Port to run the embedded server on. Defaults to 9292
|
# 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
|
# A unique identifier issued to the client to identify itself to the
|
||||||
# authorization server.
|
# authorization server.
|
||||||
# @option options [String] :client_secret
|
# @option options [String] :client_secret
|
||||||
|
@ -73,11 +73,11 @@ module Google
|
||||||
:redirect_uri => "http://localhost:#{@port}/"}.update(options)
|
:redirect_uri => "http://localhost:#{@port}/"}.update(options)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Request authorization. Opens a browser and waits for response.
|
# 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
|
# Optional object that responds to :write_credentials, used to serialize
|
||||||
# the OAuth 2 credentials after completing the flow.
|
# the OAuth 2 credentials after completing the flow.
|
||||||
#
|
#
|
||||||
|
@ -85,7 +85,7 @@ module Google
|
||||||
# Authorization instance, nil if user cancelled.
|
# Authorization instance, nil if user cancelled.
|
||||||
def authorize(storage=nil)
|
def authorize(storage=nil)
|
||||||
auth = @authorization
|
auth = @authorization
|
||||||
|
|
||||||
server = WEBrick::HTTPServer.new(
|
server = WEBrick::HTTPServer.new(
|
||||||
:Port => @port,
|
:Port => @port,
|
||||||
:BindAddress =>"localhost",
|
:BindAddress =>"localhost",
|
||||||
|
|
Loading…
Reference in New Issue