Merge pull request #94 from programmiersportgruppe/master
Shutdown WEBrick server used in installed app flow
This commit is contained in:
commit
fda7086f43
|
@ -92,9 +92,10 @@ module Google
|
|||
:Logger => WEBrick::Log.new(STDOUT, 0),
|
||||
:AccessLog => []
|
||||
)
|
||||
trap("INT") { server.shutdown }
|
||||
|
||||
server.mount_proc '/' do |req, res|
|
||||
begin
|
||||
trap("INT") { server.shutdown }
|
||||
|
||||
server.mount_proc '/' do |req, res|
|
||||
auth.code = req.query['code']
|
||||
if auth.code
|
||||
auth.fetch_access_token!
|
||||
|
@ -102,10 +103,13 @@ module Google
|
|||
res.status = WEBrick::HTTPStatus::RC_ACCEPTED
|
||||
res.body = RESPONSE_BODY
|
||||
server.stop
|
||||
end
|
||||
end
|
||||
|
||||
Launchy.open(auth.authorization_uri.to_s)
|
||||
server.start
|
||||
Launchy.open(auth.authorization_uri.to_s)
|
||||
server.start
|
||||
ensure
|
||||
server.shutdown
|
||||
end
|
||||
if @authorization.access_token
|
||||
if storage.respond_to?(:write_credentials)
|
||||
storage.write_credentials(@authorization)
|
||||
|
|
Loading…
Reference in New Issue