auth3-dev / auth3-sdk
Auth3身份平台API的库,更多信息请访问 https://auth3.dev/。
Requires
- php: >=7.0.0
- google/protobuf: ^v3.18.0
- grpc/grpc: ^v1.39.0
README
官方 Auth3 php SDK库。
API 文档
有关进一步的帮助,请查看 https://docs.auth3.dev/apis/identity-platform/administrative 的API文档。
安装
先决条件
请注意,使用此库需要在您的系统上安装 gRPC for PHP。
如果不这样做,将会导致有关gRPC库(例如,Error: Class 'Grpc\ChannelCredentials' not found
)的导入错误。在这种情况下,请确保使用 sudo pecl install grpc-<version>
安装与已解决PHP库相同版本的库,以避免任何问题。
Mac用户,如果通过 brew
安装了php,请确保使用正确的 php
二进制文件,而不是系统范围内的 /usr/bin/php
。您可以使用 brew list php
查看您的二进制文件位置(例如,/usr/local/Cellar/php/8.0.11_1/bin/php
)。如果没有这样做,可能会导致上述问题,因为 extension=grpc.so
可能已在另一个php安装上配置。
自动化
$ composer require auth3-dev/auth3-sdk
手动
使用 composer 获取库,将其添加到您的 composer.json
"require": { "auth3-dev/auth3-sdk": "^1.0.0" }
然后运行
$ composer install # or "update"
在您的代码中,您现在可以
<?php require('vendor/autoload.php'); $client = new Auth3\Identity\Admin\AdminClient('<admin-endpoint-as-found-in-your-Console>', [ 'credentials' => Grpc\ChannelCredentials::secure(), ]); $request = new Auth3\Identity\Admin\GetConnectionsRequest(); // This is how you can use setters to provide parameters to the request: // $request->setAttribute($request); // in this case it's not needed. list($response, $status) = $client->getConnections($request)->wait(); if ($status->code !== Grpc\STATUS_OK) { echo "ERROR: " . $status->code . ", " . $status->details . PHP_EOL; exit(1); } // do something with the response: // $response.getConnections()
示例
查看 examples/
文件夹,了解如何初始化客户端并执行查询。
执行它
$ cat examples/admin/main.php # customise client connection info
$ composer install
$ php -d extension=grpc.so main.php
注意 您需要将 extension=grpc.so
添加到您的php.ini文件中。或者将 -d extension=grpc.so
添加到您的命令行中以加载所需的扩展。如果不这样做,将无法解决一些库的导入问题。请参阅 文档 来设置您的环境。
其他帮助
您可以在 这里 找到更多帮助、示例、工具和建议。
更改语言
不是您的目标语言?请查看我们的官方SDK,包括
贡献
目前我们不接受外部贡献,但我们欢迎反馈和建议。我们始终欢迎在我们的安全领域做出贡献,有关更多信息,请参阅 我们的专用页面。
支持
Auth3身份平台客户可以通过我们网站上的官方渠道获得支持。出于安全原因,我们无法通过错误跟踪器处理客户请求。
许可证
阅读 LICENSE。