examples/pro_auth.rb in travis-1.10.1.travis.1341.9 vs examples/pro_auth.rb in travis-1.11.0
- old
+ new
@@ -1,23 +1,23 @@
require 'travis/pro'
require 'travis/tools/github'
require 'highline/import' # so we can hide the password
+github_token = ask("GitHub token: ")
+
# Set up GitHub tool for doing the login handshake.
github = Travis::Tools::Github.new(drop_token: true) do |g|
- g.ask_login = -> { ask("GitHub login: ") }
- g.ask_password = -> { ask("Password: ") { |q| q.echo = "*" } }
- g.ask_otp = -> { ask("Two-factor token: ") }
+ g.github_token = github_token
end
# Create temporary GitHub token and use it to authenticate against Travis CI.
github.with_token do |token|
Travis::Pro.github_auth(token)
end
# Look up the current user.
user = Travis::Pro::User.current
-puts "Hello #{user.name}!"
+puts "Hello #{user.login}!"
# Display repositories the user is a member of.
repos = Travis::Pro::Repository.find_all(member: user.login)
repos.each { |repo| puts "#{repo.slug} #{repo.last_build_state}" }