Skip to content

Commit

Permalink
Prevent errors loading deprecated installed_app file if launchy is no…
Browse files Browse the repository at this point in the history
…t present (googleapis#745)
  • Loading branch information
dazuma authored Dec 5, 2018
1 parent f6e204d commit ce9de93
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/google/api_client/auth/installed_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,29 @@
# limitations under the License.

require 'webrick'
require 'launchy'

launchy_available =
begin
require 'launchy'
true
rescue LoadError
warn "Attempted to require google/api_client/auth/installed_app.rb when" \
" launchy is not available. The InstalledAppFlow class is disabled."
false
end

module Google
class APIClient

# Small helper for the sample apps for performing OAuth 2.0 flows from the command
# line or in any other installed app environment.
#
# This class is used in some sample apps and tests but is not really part
# of the client libraries, and probably does not belong here. As such, it
# is deprecated. If you do choose to use it, note that you must include the
# `launchy` gem in your bundle, as it is required by this class but not
# listed in the google-api-client gem's requirements.
#
# @example
#
# flow = Google::APIClient::InstalledAppFlow.new(
Expand Down Expand Up @@ -125,4 +140,4 @@ def authorize(storage=nil, options={})
end

end
end
end if launchy_available

0 comments on commit ce9de93

Please sign in to comment.