【问题标题】:Braintree Authorization Exception, why?Braintree 授权异常,为什么?
【发布时间】:2016-08-12 16:47:28
【问题描述】:

我正在尝试像这样生成一个 client_token:

private static BraintreeGateway gateway = new BraintreeGateway (
            Environment.SANDBOX,
            "merchant_id",
            "public_key",
            "private_key"
    );

@ApiMethod(name = "genClientToken", path = "client_token", httpMethod = ApiMethod.HttpMethod.GET)
public ClientToken genClientToken() {
    return new ClientToken(gateway.clientToken().generate());
}

每当我这样做时,我都会收到 Braintree 授权异常,即使 Mercer_id、public_key 和 private_key 都按照 Sandbox 仪表板中的方式提供。

为什么我会收到这个com.braintreegateway.exceptions.AuthenticationException,我该如何解决这个问题?

【问题讨论】:

    标签: exception braintree


    【解决方案1】:

    调用gateway.clientToken().generate() 是生成clientToken 的正确方法,似乎有一个单独的问题with your credentials. 请通过support@braintreepayments.com 与支持人员联系以获取更多详细信息。

    【讨论】:

      【解决方案2】:

      来自https://developer.paypal.com/braintree/docs/reference/general/exceptions/dotnet#authentication-error的文档

      身份验证错误 Braintree.Exceptions.AuthenticationException

      当您的 API 密钥不正确时引发。如果你得到这个 首次集成时出现异常,请仔细检查您是否没有 不小心尝试在生产中使用您的沙盒密钥或 反之亦然。

      它说您的 API 密钥有问题。

      但是,我在从沙盒切换到生产 API 密钥时遇到了同样的错误,这与分配给创建正在使用的 API 密钥的用户的角色有关。因此,虽然 API 密钥是正确的,但由于用户权限不足而返回异常。如果 Braintree 在这种情况下返回一个不同的异常但它没有返回会更好。

      您需要在 Braintree 控制面板中为用户添加以下角色:

      交易:

      • 创建销售
      • 提交销售结算

      您可能还需要只读角色。

      这里是角色和授予权限的完整列表 https://developer.paypal.com/braintree/articles/control-panel/users-roles/role-permissions

      【讨论】:

        猜你喜欢
        • 2018-06-30
        • 2023-03-23
        • 2011-10-26
        • 1970-01-01
        • 2016-08-06
        • 2021-06-05
        • 2015-12-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多