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

"invalid_client" "Please provide valid client credentials using HTTP Basic Authentication." #466

Open
nxverma opened this issue Jan 9, 2024 · 4 comments
Labels
awaiting-response bug Something isn't working

Comments

@nxverma
Copy link

nxverma commented Jan 9, 2024

we are facing issue while running TF code . Our creds are correct as working in Postman and other

Error: Post "https://api.us-central1.gcp.commercetools.com/<project_key>/tax-categories": oauth2: "invalid_client" "Please provide valid client credentials using HTTP Basic Authentication."

@nxverma nxverma added bug Something isn't working triage Needs triage labels Jan 9, 2024
@demeyerthom
Copy link
Member

Hi @nxverma

Hmm, that is a strange error. I am assuming the provider itself is also configured correctly? Do you maybe have more information for me? When did this start happening? What are you trying to execute?

Thanks!

@demeyerthom demeyerthom added awaiting-response and removed triage Needs triage labels Jan 19, 2024
@totalbot123
Copy link

We are observing similar issues in our environments. Example error:

Post "***/***/product-types": oauth2: "invalid_client" "Please provide valid client credentials using HTTP Basic Authentication."
│ 
│   with module.commercetools.module.productType.module.product_type["product"].commercetools_product_type.this,
│   on .terraform/modules/commercetools.productType.product_type/main.tf line 1, in resource "commercetools_product_type" "this":
│    1: resource "commercetools_product_type" "this" ***

We provide:

COMMERCETOOLS_CLIENT_ID
COMMERCETOOLS_CLIENT_SECRET
COMMERCETOOLS_PROJECT_KEY
COMMERCETOOLS_SCOPES
COMMERCETOOLS_API_URL
COMMERCETOOLS_TOKEN_URL

Scopes given: manage_project:our-project view_audit_log:our-project manage_api_clients:our-project view_api_clients:our-project

Plan worked as expected but we are observing this on apply.

Provider version: 1.14.1
Environment: GH (RHEL container)

@motizukilucas
Copy link

Hi any updates on this topic?

I ran into the same issue with following terraform code:

terraform {
    required_providers {
        commercetools = {
            source  = "labd/commercetools"
        }
    }
}

provider "commercetools" {
    client_id     = var.client_id
    client_secret = var.client_secret
    project_key   = var.project_key
    scopes        = "manage_project,manage_products,manage_orders,manage_customers,manage_categories,manage_types,manage_zones" # https://docs.commercetools.com/merchant-center-customizations/concepts/oauth-scopes-and-user-permissions#oauth-scopes
    api_url       = "https://api.europe-west1.gcp.commercetools.com/" # https://docs.commercetools.com/api/general-concepts#hosts
    token_url     = "https://auth.europe-west1.gcp.commercetools.com/" # https://docs.commercetools.com/api/authorization
}

resource "commercetools_store" "my-client-a-store" {
    key = "my-client-A-store"
    name = {
    en-US = "My client A"
    }
    countries             = ["US", "UK"]
    languages             = ["en-US", "en-UK"]
}

@motizukilucas
Copy link

Managed to get a working setup with following terraform, by appending authentication in token_url as shown here: https://docs.commercetools.com/getting-started/make-first-api-call#auth-url-and-parameters

terraform {
    required_providers {
        commercetools = {
            source  = "labd/commercetools"
        }
    }
}

provider "commercetools" {
    client_id     = var.client_id
    client_secret = var.client_secret
    project_key   = var.project_key
    scopes = "manage_project:${var.project_key}"
    api_url       = "https://api.europe-west1.gcp.commercetools.com/" # https://docs.commercetools.com/api/general-concepts#hosts
    token_url     = "https://${var.client_id}:${var.client_secret}@auth.europe-west1.gcp.commercetools.com/" # https://docs.commercetools.com/api/authorization
}

resource "commercetools_store" "my-client-a-store" {
    key = "my-client-A-store"
    name = {
    en-US = "My client A"
    }
    countries             = ["US", "UK"]
    languages             = ["en-US", "en-GB"]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants