# Incorrect Authorization Header

**URL:** <https://community.postman.com/t/incorrect-authorization-header/38305>\
**Category:** Help Hub\
**Tags:** authentication\
**Created:** [August 18, 2022, 5:46pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305 "2022-08-18T17:46:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdinosogsb](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@rdinosogsb](https://community.postman.com/u/rdinosogsb)\
**Post date:** [August 18, 2022, 5:46pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/1 "2022-08-18T17:46:41Z")

</div>

_My question_: I’m trying to configure my Walmart All Order Released api, but I’m getting an incorrect authorization header error. Postman is not liking the header “Authorization” key to have the an Base64 encoded client ID with the word "Basic " in front of the coded client ID. I also assumed that the “WM\_SEC.ACCESS\_TOKEN” key to have the Base64 encoded value of my client secret.

The encoding was done by an online service: [https://www.base64encode.org/](https://www.base64encode.org/) and selecting the UTF-8 character set.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 19, 2022, 9:06pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/2 "2022-08-19T21:06:21Z")

</div>

Hi @rdinosogsb

Can you share a screenshot of what you have tried and the console log output (bottom left of the screen)?

---

<div class="post-metadata">

**Author:** ![eca.2889](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@eca.2889](https://community.postman.com/u/eca.2889)\
**Post date:** [August 24, 2022, 7:22pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/3 "2022-08-24T19:22:15Z")

</div>

Hi! were you able to solve it? I am having the same error and my keys are correct.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 25, 2022, 9:28am UTC](https://community.postman.com/t/incorrect-authorization-header/38305/4 "2022-08-25T09:28:50Z")

</div>

You said you encoded the ClientID with the word basic in fornt of it [but when reading the docs](https://developer.walmart.com/api/us/mp/orders#operation/getAllReleasedOrders) it suggests that it should be the ClientID and Client Secret that gets base64 encoded.

> Example: Basic YzcyOTFjNmItNzI5MC00…
> 
> Basic authorization header. Base 64 encodes the Client ID and Client Secret retrieved in step two of the integration steps.

---

<div class="post-metadata">

**Author:** ![rdinosogsb](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@rdinosogsb](https://community.postman.com/u/rdinosogsb)\
**Post date:** [August 25, 2022, 2:59pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/5 "2022-08-25T14:59:01Z")

</div>

![image](https://us1.discourse-cdn.com/getpostman/original/2X/c/ca0bbe3705c9be5c2a139769929acdd0a0d49560.png)

---

<div class="post-metadata">

**Author:** ![rdinosogsb](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@rdinosogsb](https://community.postman.com/u/rdinosogsb)\
**Post date:** [August 25, 2022, 3:02pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/6 "2022-08-25T15:02:09Z")

</div>

Both the ClientID and the Client Secret are Base64 encoded, and I removed the word “Basic” from the Client ID. I’m thinking the various URLs are incorrect. For the baseURL variable I used [https://marketplace.walmartapis.com](https://marketplace.walmartapis.com).

---

<div class="post-metadata">

**Author:** ![rdinosogsb](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@rdinosogsb](https://community.postman.com/u/rdinosogsb)\
**Post date:** [August 25, 2022, 3:20pm UTC](https://community.postman.com/t/incorrect-authorization-header/38305/7 "2022-08-25T15:20:27Z")

</div>

Here’s my error message:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/5/5864ac3cdf1c6943d2ba6b5a550b60094dcd46b7.png)

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [August 26, 2022, 11:01am UTC](https://community.postman.com/t/incorrect-authorization-header/38305/8 "2022-08-26T11:01:35Z")

</div>

Is {{Authorisation}} your ClientID and {{WM\_SEC.ACCESS\_TOKEN}} your Client Secret? … before anything gets changed?

Looking at the official docs, these two values are very different from what you are feeding in here…

Also, above the section in your screenshot, there is also a pre-fix, is this still set to “Bearer” … looks like the prefix is “Basic”.

* * *

The make-up of the Auth header should be something like this;

```auto
const ClientID = 'my-3x4mpl3-cl13n7-1d';
const ClientSec = 'my-3x4mpl3-53cr37';
let base64Auth = btoa(ClientID + ":" + ClientSec);
console.log('Basic ' + base64Auth);

```

Output;  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/5/528a7f7ed688b121ecdc3247d79af92ec7b30cfa.png)

Your header would then look like;  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/4/4e1d7483bd89dcb7af4aa7b2106f1ce7cb9a8806.png)

* * *

Not 100% sure how it currently builds it, but you could check in the console log to see what the base64 value is and then decode it to see if it is the correct format (separated with a `:` colon).

---

<div class="post-metadata">

**Author:** ![navigation-pilot-555](https://avatars.discourse-cdn.com/v4/letter/n/41988e/32.png) [@navigation-pilot-555](https://community.postman.com/u/navigation-pilot-555)\
**Post date:** [September 7, 2022, 9:06am UTC](https://community.postman.com/t/incorrect-authorization-header/38305/9 "2022-09-07T09:06:56Z")

</div>

Here to say that I’m encountering the very same issue.

Trying to generate token according to api documentation:

> **[DeveloperPortal](https://developer.walmart.com/api/us/mp/auth#operation/tokenAPI)**

Sending post request like that (except login and pw are replaced accordingly. Tried to attach collection as a file, but apparently I can’t do that, so pasted below):

```auto
{
	"info": {
		"_postman_id": "9f3aabae-3317-4c62-bbd1-fa891aa1b64d",
		"name": "walmart test",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "22134029"
	},
	"item": [
		{
			"name": "New Request",
			"protocolProfileBehavior": {
				"disabledSystemHeaders": {
					"accept": true
				}
			},
			"request": {
				"auth": {
					"type": "basic",
					"basic": [
						{
							"key": "password",
							"value": "client_secret",
							"type": "string"
						},
						{
							"key": "username",
							"value": "client_id",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [
					{
						"key": "WM_SVC.NAME",
						"value": "Walmart Service Name asda",
						"type": "text"
					},
					{
						"key": "Accept",
						"value": "application/json",
						"type": "text"
					},
					{
						"key": "WM_QOS.CORRELATION_ID",
						"value": "test",
						"type": "text"
					},
					{
						"key": "WM_SVC.VERSION",
						"value": "1.0.0",
						"type": "text"
					}
				],
				"body": {
					"mode": "urlencoded",
					"urlencoded": [
						{
							"key": "grant_type",
							"value": "client_credentials",
							"type": "text"
						}
					]
				},
				"url": {
					"raw": "https://marketplace.walmartapis.com/v3/token",
					"protocol": "https",
					"host": [
						"marketplace",
						"walmartapis",
						"com"
					],
					"path": [
						"v3",
						"token"
					]
				}
			},
			"response": []
		}
	]
}

```

Getting the following response:

```auto
{
    "error": [
        {
            "code": "INVALID_REQUEST_HEADER.GMP_GATEWAY_API",
            "field": "Authorization",
            "description": "Incorrect Authorization header",
            "info": "One or more request headers are invalid.",
            "severity": "ERROR",
            "category": "DATA",
            "causes": [],
            "errorIdentifiers": {}
        }
    ]
}

```

I’m out of ideas what exactly went wrong and how to solve it. If anyone has any tips - that would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![supply-candidate-615](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@supply-candidate-615](https://community.postman.com/u/supply-candidate-615)\
**Post date:** [October 1, 2024, 8:37am UTC](https://community.postman.com/t/incorrect-authorization-header/38305/10 "2024-10-01T08:37:46Z")

</div>

I have solved this problem, the clientId and the clientSecret can not use original to request.  
You should decode both of them.

```auto
like:int cKeyLength = 4;
            String keyMD5 = md5(key);
            String keyA = md5(keyMD5.substring(0, 16));
            String keyB = md5(keyMD5.substring(16, 32));
            String curTime = md5(String.valueOf(System.currentTimeMillis()));
            String keyC = decode ? authString.substring(0, cKeyLength): curTime.substring(curTime.length()-cKeyLength);

            String cryptKey = keyA + md5(keyA + keyC);
            byte[] keyBytes = cryptKey.getBytes("ASCII");
            String hash = String.format("%010d", 0) + md5(authString + keyB).substring(0, 16) + authString;
            byte[] dataBytes = decode ? Base64.getDecoder().decode(authString.substring(cKeyLength)) : hash.getBytes("ASCII");
            int[] box = new int[256];
            for (int i = 0; i < 256; i++) {
                box[i] = i;
            }

            int[] rndKey = new int[256];
            for (int i = 0; i <= 255; i++) {
                rndKey[i] = keyBytes[i % keyBytes.length];
            }

            for (int j = 0, i = 0; i < 256; i++) {
                j = (j + box[i] + rndKey[i]) % 256;
                int temp = box[i];
                box[i] = box[j];
                box[j] = temp;
            }

            byte[] result = new byte[dataBytes.length];
            for (int a = 0, j = 0, i = 0; i < dataBytes.length; i++) {
                a = (a + 1) % 256;
                j = (j + box[a]) % 256;
                int temp = box[a];
                box[a] = box[j];
                box[j] = temp;
                result[i] = (byte) ((dataBytes[i]) ^ (box[(box[a] + box[j]) % 256]));
            }

            String decrypted = new String(result, "ASCII");
            if (decode){
                long currentTime = System.currentTimeMillis() / 1000;
                if ((Long.parseLong(decrypted.substring(0, 10)) == 0 || Long.parseLong(decrypted.substring(0, 10)) - currentTime > 0)
                        && decrypted.substring(10, 26).equals(md5(decrypted.substring(26) + keyB).substring(0, 16))) {
                    return decrypted.substring(26);
                } else {
                    return "";
                }
            } else {
                return keyC + new String(Base64.getEncoder().encode(result), "ASCII").replace("=", "");
            }

```

the key is the salt,maybe you could find it in your seller information.

and then this is the return the really `Authorization:headers.setBasicAuth(clientId, clientSecret);`

this is how I solve it

---

<div class="post-metadata">

**Author:** ![cosjef](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/cosjef/32/31731_2.png) [@cosjef](https://community.postman.com/u/cosjef)\
**Post date:** [February 24, 2025, 12:59am UTC](https://community.postman.com/t/incorrect-authorization-header/38305/11 "2025-02-24T00:59:27Z")

</div>

@supply-candidate-615,

I do not understand your Java code above; it seems to contain some custom symmetric encryption. How did you solve this, exactly? Are you base64 encoding the clientID:clientSecret for the Auth header? My understanding is the Auth header should be something like:  
Authorization: Basic \<base64\_encoded\_clientID:clientSecret\>

Is that correct?
