Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The requested URL returned error: 401 Unauthorized when ATLAS_TOKEN env is set #11088

Closed
francomile opened this issue Sep 26, 2019 · 5 comments

Comments

@francomile
Copy link

Vagrant version

Vagrant 2.2.5

Host operating system

Mac OSX Mojave 10.14.16
and
Ubuntu 18.04 LTS

Guest operating system

Ubuntu 18.04 LTS

Vagrantfile

No Vagrantfile is being used as i'm running the command vagrant box add <box_name>

Debug output

https://gist.github.com/francomile/762b83bae0d63202d7888503e35aee4c

Expected behavior

Vagrant should be able to access the box url and download it.

Actual behavior

IF ATLAS_TOKEN env is set, the command vagrant box add <box_name> returns the below error. If ATLAS_TOKEN is unset the public boxes can be downloaded, but not private ones of course.

Error: The requested URL returned error: 401 Unauthorized
The box 'ubuntu/bionic64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://vagrantcloud.com/ubuntu/bionic64"]
Error: The requested URL returned error: 401 Unauthorized
 INFO interface: Machine: error-exit ["Vagrant::Errors::BoxAddShortNotFound", "The box 'ubuntu/bionic64' could not be found or\ncould not be accessed in the remote catalog. If this is a private\nbox on HashiCorp's Vagrant Cloud, please verify you're logged in via\n`vagrant login`. Also, please double-check the name. The expanded\nURL and error message are shown below:\n\nURL: [\"https://vagrantcloud.com/ubuntu/bionic64\"]\nError: The requested URL returned error: 401 Unauthorized"]

Steps to reproduce

  1. echo 'export ATLAS_TOKEN="your_token_here"' > .bashrc
  2. source .bashrc
  3. vagrant box add ubuntu/bionic64 (or any other box)

References

Are there any other GitHub issues (open or closed) that should be linked here?
For example:
Found no references for this Vagrant version (2.2.5) or similar issues related with not being able to download boxes when ATLAS_TOKEN env is set.

@briancain
Copy link
Member

Hi @francomile - Does it work if you replace ATLAS_TOKEN with VAGRANT_CLOUD_TOKEN instead? Thanks.

@francomile
Copy link
Author

francomile commented Sep 26, 2019

Hi @briancain,
Unfortunately not , before opening the issue I've tried with both envs, ATLAS_TOKEN and after with VAGRANT_CLOUD_TOKEN If the env is set there's no way I can add/download a box without unsetting the env first.
The problem is that I need to have the token env set as my Packer build relies on the token to push the box at a final stage to Vagrant Cloud private repo.
I have the same issue both in Mac OSX and Ubuntu 18.04 with Vagrant 2.2.5

@briancain
Copy link
Member

Hi @francomile - You should be able to use VAGRANT_CLOUD_TOKEN for both Packer and Vagrant.

Can you explain what you mean by this?

If the env is set there's no way I can add/download a box without unsetting the env first.

Do you mean if you set VAGRANT_CLOUD_TOKEN, you get a 401 unauthorized? Are you sure the token you are using has the right permissions to access the box you are requesting? Thanks!

@francomile
Copy link
Author

@briancain ok it's now solved.
While checking the token permissions I saw a notification in my account security settings for mandatory enablement of 2FA on Vagrant cloud organisation account, so this should be preventing me from being able to download the boxes when the token var was exported as my access was most probably be blocked while 2fA was not enabled. After enabling 2FA the issue got solved.
Anyway even if I'm not able to access a private box due to permissions, that shouldn't prevent me from downloading public ones. Don't you agree?
Thanks for your assistance, I will close this ticket now.

@ghost
Copy link

ghost commented Jan 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants