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

401 Unauthorized error with correct credentials. #63

Open
mehdizj2000 opened this issue Jan 28, 2022 · 1 comment
Open

401 Unauthorized error with correct credentials. #63

mehdizj2000 opened this issue Jan 28, 2022 · 1 comment

Comments

@mehdizj2000
Copy link

mehdizj2000 commented Jan 28, 2022

I followed the documentation and set up my API credentials as below:

public static Properties getMyMerchantDetails() {
		Properties props = new Properties();

		// HTTP_Signature = http_signature and JWT = jwt
		props.setProperty("authenticationType", "http_signature");
		props.setProperty("merchantID", "my_web_au");
		props.setProperty("runEnvironment", "apitest.cybersource.com");
		
		props.setProperty("merchantKeyId", "my_merchant_id");
		props.setProperty("merchantsecretKey", "my_sercret_key");
		props.setProperty("useMetaKey", "false");
		props.setProperty("enableClientCert", "false");

		return props;

	}

it gives me 401 unauthorized error:
Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://apitest.cybersource.com/pts/v2/payments}

public static Properties getMerchantDetails() {
		Properties props = new Properties();

		// HTTP_Signature = http_signature and JWT = jwt
		props.setProperty("authenticationType", "http_signature");
		props.setProperty("merchantID", "testrest");
		props.setProperty("runEnvironment", "apitest.cybersource.com");
		props.setProperty("requestJsonPath", "src/main/resources/request.json");

		props.setProperty("useMetaKey", "false");

		// HTTP Parameters
		props.setProperty("merchantKeyId", "ggggggggggg");
		props.setProperty("merchantsecretKey", "gggggggggg");
		props.setProperty("enableClientCert", "false");
	
		return props;

	}

The above gives which is me 201 proper response.

I am sure my credentials are correctly created. Is there anything else I should add or modify to get past authorization?

@rajvpate
Copy link

@mehdizj2000 :

Looking at the example code you have pasted, please ensure that
you use your "merchantId" from Sandbox environment in this code line below
props.setProperty("merchantID", "my_web_au");
and provide the "keyId" generated using Enterprise Business Center login for your merchant in the code line below:

	props.setProperty("**merchantKeyId**", "**my_merchant_id**");

I am unable to look up your merchantID "my_web_au" in the Business Center.

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

No branches or pull requests

2 participants