【问题标题】:Square Connect API | Generate Personal Access Token via APISquare 连接 API |通过 API 生成个人访问令牌
【发布时间】:2019-10-10 09:14:03
【问题描述】:

我正在使用 Square Dashboard 中的个人访问令牌通过 Square Connect PHP SDK 创建付款。

一切正常,现在我在文档中的某处读到访问令牌每 30 天过期一次。这意味着我网站上的付款将在 30 天后停止工作?因为我找不到任何 API 来获取新的个人访问令牌。而且我不想每 30 天手动插入一次访问令牌。

        $api_config = new \SquareConnect\Configuration();
        $api_config->setHost($host_url);
        $api_config->setAccessToken($access_token);
        $api_client = new \SquareConnect\ApiClient($api_config);        
        $payments_api = new \SquareConnect\Api\PaymentsApi($api_client);

        $request_body = array (
        "source_id" =>$data['nonce'],
        "amount_money" => array (
        "amount" => $amount,
        "currency" => $currency
        ),
        "shipping_address" => array (
            "address_line_1" => $data['address_1'],
            "address_line_2" => $data['address_2'],
            "postal_code" => $data['postal_code'],
            "country" => $data['country'],
            "first_name"  => $data['first_name'],
            "last_name" => $data['last_name'],
        ),
        "customer_id" => $transaction->user_id,
        "buyer_email_address" => $data['email'],
        "reference_id" => $transaction->id,
        "note" => $note,
        "idempotency_key" => uniqid()
        );

P.S:Square API 文档是有史以来最糟糕的文档!!!

【问题讨论】:

  • 如果您认为 Square 的文档很糟糕,这说明您在一天中没有阅读大量文档。这实际上是我见过的一些更好的书面文档。

标签: php wordpress square-connect square


【解决方案1】:

个人访问令牌永不过期。如果您使用 OAuth,则访问令牌确实每 30 天过期一次,您可以使用 ObtainTokenrefresh_token 来生成新的访问令牌。

此外,请随时将您对我们文档的反馈发送给 Square 的 Developer Support 团队,以便我们改进。

【讨论】:

  • 这样可以无限期使用而无需更换?使用个人访问令牌是否安全?
  • 在以下链接上:[link]developer.squareup.com/docs/api/… 它说:除了您的应用程序的个人访问令牌之外的 OAuth 访问令牌将在 30 天后过期。 这让我感到困惑,因为这意味着个人访问令牌也会过期。
  • "besides" 表示个人访问令牌不包含在语句的其余部分中。您可以永远使用它而无需更换。它在技术上是安全的,是的,尽管我们通常建议使用 OAuth 令牌来限制权限范围。不过,最终,使用个人访问令牌不会造成任何伤害。
  • 好的,谢谢先生。我想我需要学习我的英语:D
猜你喜欢
  • 2019-12-18
  • 1970-01-01
  • 1970-01-01
  • 2020-05-06
  • 2019-02-08
  • 2014-11-01
  • 2015-11-16
  • 2022-08-18
  • 2022-11-11
相关资源
最近更新 更多