Skip to content

Commit

Permalink
Merge pull request googleapis#94 from programmiersportgruppe/master
Browse files Browse the repository at this point in the history
Shutdown WEBrick server used in installed app flow
  • Loading branch information
sgomes committed Sep 17, 2014
2 parents 6f65502 + c428db0 commit fda7086
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/google/api_client/auth/installed_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,24 @@ def authorize(storage=nil)
: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!
end
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)
Expand Down

0 comments on commit fda7086

Please sign in to comment.