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

Authentication error when attempting to use org token #3

Closed
zbuchheit opened this issue Aug 9, 2024 · 3 comments
Closed

Authentication error when attempting to use org token #3

zbuchheit opened this issue Aug 9, 2024 · 3 comments

Comments

@zbuchheit
Copy link
Contributor

zbuchheit commented Aug 9, 2024

When attempting to use the provider for the first time I am encountering an authentication error. I am attempting to authenticate via MIST_API_TOKEN using an org token. I have verified the API token is valid.

Error Message

│ Error: Authentication Error
│ 
│   with provider["registry.terraform.io/juniper/mist"],
│   on <empty> line 0:
│   (source code not available)
│ 
│ required field `email` is missing for type `Admin`
│ required field `first_name` is missing for type `Admin`
│ required field `last_name` is missing for type `Admin`

Repro

terraform {
  required_providers {
    mist = {
      source = "juniper/mist"
      version = "0.1.16"
    }
  }
}

data "mist_sites" "sites" {
  org_id  =  "redacted"
}

Additional Context

It appears this error message is coming from validation in the mistapi-go admin struct

@zbuchheit zbuchheit changed the title Required field error when attempting to use provider Authentication error when attempting to use provider via api token Aug 9, 2024
@zbuchheit
Copy link
Contributor Author

zbuchheit commented Aug 9, 2024

I believe specifically the issue is coming from using an org token with

_, err := client.SelfAccount().GetSelf(ctx)
where SelfAccount won't respond with first_name last_name or email.

It will only respond with an object like

{
    "name": "pulumi-test-token",
    "privileges": [
        {
            "scope": "org",
            "org_id": "redacted",
            "role": "admin",
            "name": "Test Org"
        }
    ]
}

so that will cause the model validation to fail as referenced above

@zbuchheit zbuchheit changed the title Authentication error when attempting to use provider via api token Authentication error when attempting to use org token Aug 9, 2024
@tmunzer
Copy link
Collaborator

tmunzer commented Aug 10, 2024

Hi @zbuchheit ,

I updated the mistapi-go SDK to fix the issue, and updated the terraform provider to use the latest version of the SDK. This issue should be fixed.

Thanks.

@zbuchheit
Copy link
Contributor Author

Fixed via newest release of the SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants