mongodb-atlas-cli icon indicating copy to clipboard operation
mongodb-atlas-cli copied to clipboard

"atlas" CLI reports "You are not authorized for this resource" when "mongocli atlas" does not

Open SteveH-US opened this issue 2 years ago • 4 comments

Describe the bug A clear and concise description of the bug.

As requested, I followed the migration steps for using "atlas" rather than "mongocli atlas". However, I'm not getting the "You are not authorized for this resource" errors for the same configuration, but running the same comment through "mongocli atlas" works. I have "organizational" owner" rights.

To Reproduce Using mongocli

$ mongocli iam projects list | grep "\"id\":" | wc -l
      11

Using atlas

$ atlas projects list
Error: GET https://cloud.mongodb.com/api/atlas/v1.0/groups?itemsPerPage=100&pageNum=1: 401 (request "") You are not authorized for this resource.

Expected behavior Please explain what you expected to happen.

Screenshots If possible, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Mac OS 12.3.1 M1Pro
  • MongoCLI version 1.24.1
  • Atlas cli version1.0.2
  • Ops Manager Version: N/A

Additional context Add any other context about the problem here.

SteveH-US avatar Apr 19 '22 16:04 SteveH-US

Hi @SteveH-US before I look into possible errors on our side can you please confirm that the config files look a like? to open the config file for mongocli you can do mongocli config edit for atlas you can do vi ~/Library/Application\ Support/atlascli/config.toml

gssbzn avatar Apr 19 '22 16:04 gssbzn

Also to confirm, was the migration relying on the automated atlas cli config file creation or was this related to an automated pipeline that required manual intervention for the file?

gssbzn avatar Apr 19 '22 17:04 gssbzn

@gssbzn

Here's my config file with the keys redacted

mongosh_path = "/Users/steveh_1/.mongodb/mongosh"
skip_update_check = true

[default]
  mongosh_path = "/opt/homebrew/bin/mongosh"
  org_id = "***"
  output = "json"
  private_api_key = "***"
  project_id = "***"
  public_api_key = "***"
  service = "cloud"

[mom_mia]
  ops_manager_url = "https://mama.mia.ulti.io/"
  organization_id = "***"
  private_api_key = "***"
  project_id = "***"
  public_api_key = "***"
  service = "ops-manager"

I followed the migration instructions. It appears that the atlas config init command reused the mongocli config file that was there already.

SteveH-US avatar Apr 19 '22 18:04 SteveH-US

There appears to be a bug in the way the atlas cli handles the init. It appears to copy the mongocli configuration as is when running atlas config init. I say this because when I rename the existing file, "~/Library/Application\ Support/atlascli/config.toml" and run 'atlas config init' again, I am able to get the expected results back. So, it appears that a mongocli configuration it copied, the one quoted above, causes the said erroneous error.

SteveH-US avatar May 19 '22 17:05 SteveH-US

This issue has gone 30 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

github-actions[bot] avatar Oct 18 '22 14:10 github-actions[bot]