instance method
Gem::GemcutterUtilities#sign_in
sign_in(sign_in_host = nil, scope: nil)
lib/rubygems/gemcutter_utilities.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/gemcutter_utilities.rb, line 155
def sign_in(sign_in_host = nil, scope: nil)
sign_in_host ||= host
return if api_key
pretty_host = pretty_host(sign_in_host)
say "Enter your #{pretty_host} credentials."
say "Don't have an account yet? " \
"Create one at #{sign_in_host}/sign_up"
identifier = ask "Username/email: "
password = ask_for_password " Password: "
say "\n"
key_name = get_key_name(scope)
scope_params = get_scope_params(scope)
profile = get_user_profile(identifier, password)
mfa_params = get_mfa_params(profile)
all_params = scope_params.merge(mfa_params)
warning = profile["warning"]
credentials = { identifier: identifier, password: password }
say "#{warning}\n" if warning
response = rubygems_api_request(:post, "api/v1/api_key",
sign_in_host, credentials: credentials, scope: scope) do |request|
request.basic_auth identifier, password
request.body = Gem::URI.encode_www_form({ name: key_name }.merge(all_params))
end
with_response response do |resp|
say "Signed in with API key: #{key_name}."
set_api_key host, resp.body
end
end
Signs in with the RubyGems API at sign_in_host and sets the rubygems API key.
See also
#set_api_key
#update_scope
#rubygems_api_request
#verify_api_key
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0