{"record":{"id":"a2248c360f7ccd44","repo":"hashicorp/vagrant","slug":"requesting-2fa-code-via-delivery-method-upcase","errorCode":null,"errorMessage":"Requesting 2FA code via #{delivery_method.upcase}...","messagePattern":"Requesting 2FA code via #(.+?)\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"plugins/commands/cloud/client/client.rb","lineNumber":98,"sourceCode":"\n        Vagrant::Util::CredentialScrubber.sensitive(password)\n        with_error_handling do\n          r = client.authentication_token_create(username: username_or_email,\n            password: password, description: description, code: code)\n\n          Vagrant::Util::CredentialScrubber.sensitive(r[:token])\n          @client = VagrantCloud::Client.new(\n            access_token: r[:token],\n            url_base: api_server_url\n          )\n          r[:token]\n        end\n      end\n\n      # Requests a 2FA code\n      # @param [String] delivery_method\n      def request_code(delivery_method)\n        @env.ui.warn(\"Requesting 2FA code via #{delivery_method.upcase}...\")\n\n        Vagrant::Util::CredentialScrubber.sensitive(password)\n        with_error_handling do\n          r = client.authentication_request_2fa_code(\n            username: username_or_email, password: password, delivery_method: delivery_method)\n\n          two_factor = r[:two_factor]\n          obfuscated_destination = two_factor[:obfuscated_destination]\n\n          @env.ui.success(\"2FA code sent to #{obfuscated_destination}.\")\n        end\n      end\n\n      # Stores the given token locally, removing any previous tokens.\n      #\n      # @param [String] token\n      def store_token(token)\n        Vagrant::Util::CredentialScrubber.sensitive(token)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/cloud/client/client.rb#L80-L116","documentation":"Informational notice printed by the cloud client (plugins/commands/cloud/client/client.rb) at the start of request_code, the 2FA delivery step of `vagrant cloud auth login`. It announces 'Requesting 2FA code via SMS/EMAIL...' (delivery_method upcased), scrubs the password from logs via CredentialScrubber, calls authentication_request_2fa_code, and on success prints '2FA code sent to <obfuscated destination>.' It is a progress message, not a failure.","triggerScenarios":"Running `vagrant cloud auth login` for an account with two-factor authentication enabled; the client detects 2FA is required and calls request_code('sms') or request_code('email') before prompting for the code.","commonSituations":"First login on a new machine/CI runner with a 2FA-protected Vagrant Cloud account; users surprised a code arrives by SMS when they expected email (delivery method chosen by account settings); retrying login after a wrong code.","solutions":["Check the announced channel and your device for the code, then enter it at the prompt.","If the code never arrives, verify the delivery method configured on your Vagrant Cloud account and retry login.","For non-interactive automation, avoid 2FA entirely: create a personal access token (vagrant cloud auth token) in the web UI and use `vagrant cloud auth login --token`.","If request fails, the surrounding with_error_handling block surfaces the VagrantCloud error — fix credentials/network based on that message."],"exampleFix":"# before (interactive, 2FA each time)\nvagrant cloud auth login   # -> Requesting 2FA code via SMS...\n\n# after (automation: token, no 2FA prompt)\nvagrant cloud auth login --token $VAGRANT_CLOUD_TOKEN","handlingStrategy":"fallback","validationCode":"# skip interactive 2FA in automation: pre-provision a token\n[ -n \"$VAGRANT_CLOUD_TOKEN\" ] || { echo \"set VAGRANT_CLOUD_TOKEN for headless login\" >&2; exit 1; }\nvagrant cloud auth login --token \"$VAGRANT_CLOUD_TOKEN\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create a dedicated access token for CI instead of username/password with 2FA.","Confirm the account's 2FA delivery method (SMS vs email) before scripting logins.","Store the token via secret management, not in the Vagrantfile or env files committed to git."],"tags":["vagrant","vagrant-cloud","two-factor-auth","login-flow","progress-message"],"backgroundTag":"two-factor-challenge-required","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}