Loading

New API Client ID not working - HTTP 401 Unauthorized

Julkaisupäivä: Jan 18, 2023
Kuvaus
New clientID for API not working

The message we are getting back when requesting the OAuth token is as follows:

“401 Unauthorized” 
{
"error_description": "Client authentication failed",
"error": "invalid_client"
}

When performing the same exact process with the Demo User, except changing out the ID and credentials, this process works fine.New
Ratkaisu
Description : New clientID for API not working

The message we are getting back when requesting the OAuth token is as follows:

“401 Unauthorized” 
{
"error_description": "Client authentication failed",
"error": "invalid_client"
}

When performing the same exact process with the Demo User, except changing out the ID and credentials, this process works fine.New

Environment : Instance Type: All

Probable Cause : You need to add the new client ID to Business Manager:

Administration >  Site Development >  Open Commerce API Settings

For example:
{
  "_v":"13.6",
  "clients":
  [ 
    {
      "client_id":"2ca8b4f3-e97b-4c3a-baea-2326bd7bb666",
      "allowed_origins":["http://www.mystore.com","https://www.mystore.com","http://staging-store-mystore.demandware.net","https://staging-store-mystore.demandware.net"],
      "resources":
      [
        {
          "resource_id":"/account/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/register",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/login",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/logout",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/account/{id}/addresses",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/add",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_shipping_address",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_billing_address",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_shipping_method",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_customer_info",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/set_payment_method",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/shipping_methods",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/payment_methods",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        },
        {
          "resource_id":"/basket/{id}/checkout/submit",
          "read_attributes":"(**)",
          "write_attributes":"(**)"
        }, 
        {
          "resource_id":"/categories/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/images",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/availability",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":60
        },
        {
          "resource_id":"/products/{id}/prices",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "config":{
             "product.prices.price_book_ids":"pricebook-listprice,pricebook-saleprice,pricebook-clearanceprice"
          },
          "cache_time":300
        },
        {
          "resource_id":"/products/{id}/links",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/promotions",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/options",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/set_products",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/bundled_products",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/links",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/products/{id}/variations",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/product_search",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/product_search/availability",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":60
        },
        {
          "resource_id":"/product_search/images",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "config":{
            "search_result.hits.image:view_type":"hi-res",
            "search_result.variation_attributes.values.image:view_type":"1200_1700",
            "search_result.variation_attributes.values.image_swatch:view_type":"swatch"
          },
          "cache_time":300
        },
        {
          "resource_id":"/product_search/prices",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":300
        },
        {
          "resource_id":"/product_search/variations",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/promotions",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/promotions/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/site",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/folders/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/content_search",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },        
        {
          "resource_id":"/content/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/stores",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        },
        {
          "resource_id":"/stores/{id}",
          "read_attributes":"(**)",
          "write_attributes":"(**)",
          "cache_time":900
        }        
      ]
    }
  ]
}

Resolution : Configure OCAPI Settings in Business Manager
Knowledge-artikkelin numero

000391311

 
Ladataan
Salesforce Help | Article