Reputation: 3163
I am using braintree java api version 2.48.0 for with the v2 javascript. In order to create a drop in from i need to create client token. But whenever i am requesting for a client token i am getting AuthorizationException.
Code:
private static BraintreeGateway gateway = new BraintreeGateway(
Environment.SANDBOX,
"merchant_id",
"public_key",
"private_key");
public static String getToken() {
String token = gateway.clientToken().generate(); // This line throws exception.
System.out.println("[DEBUG] Genareted Token " + token);
return token;
}
Exception:
Exception in thread "main" com.braintreegateway.exceptions.AuthorizationException
at com.braintreegateway.util.Http.throwExceptionIfErrorStatusCode(Http.java:191)
at com.braintreegateway.util.Http.httpRequest(Http.java:89)
at com.braintreegateway.util.Http.post(Http.java:51)
at com.braintreegateway.ClientTokenGateway.generate(ClientTokenGateway.java:37)
at com.braintreegateway.ClientTokenGateway.generate(ClientTokenGateway.java:31)
at com.tigerworks.payment.BraintreeService.getToken(BraintreeService.java:20)
at com.tigerworks.payment.Program.main(Program.java:14)
How i can overcome this? where is the problem.
NB: The braintree object creation is provided by braintree control panel. so there is no posibality that is wrong. Though i am registerd under my official team.
Upvotes: 3
Views: 1155
Reputation: 417
I work as a developer at Braintree. You are seeing an AuthorizationException
because you need to replace the merchant_id
, public_key
, and private_key
values with your credentials. Navigate to "Setting" > "Users and Roles" in your Sandbox Control Panel. Go into your user page and click on "API Keys" to manage your API Keys. Click on the one you want to use and you will find these values listed there.
Upvotes: 1