iodatacenters / oktasdk
1.2.12
2018-05-11 15:10 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.1
Requires (Dev)
- phpdocumentor/phpdocumentor: ^2.8
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2020-01-27 19:06:05 UTC
README
!!! 未维护 !!! - 此库不再维护。建议您切换到官方 okta/sdk
库。
Okta API (v1) 的 PHP 客户端库
有关每个资源/组件的更多信息,请参阅完整的 Okta API 文档。
使用 Composer 安装
composer require iodatacenters/oktasdk
初始化客户端
要初始化客户端对象,您必须以参数的形式传入您的 Okta 组织子域名和 API 密钥。例如,如果您的 Okta 域名是 https://foo.okta.com
,则您的 org 前缀是 foo
。有关如何获取组织的 API 密钥的说明,请参阅 获取令牌。
示例
use Okta; $okta = new Okta\Client('foo', 'api_key');
您也可以可选地作为第三个参数传递一个配置选项数组
$okta = new Okta\Client('foo', 'api_key', [ 'bootstrap' => false, // Don't auto-bootstrap the Okta resource properties 'preview' => true, // Use the okta preview (oktapreview.com) domain 'headers' => [ 'Some-Header' => 'Some value', 'Another-Header' => 'Another value' ] ]);
用法
所有 Okta 资源都可通过 $okta->$resource->$method
语法获取,其中 $resource
是资源的单数、小写名称(例如 - Users = user
,Groups = group
等),而 $method
是方法名称(请参阅文档了解所有可用方法)。唯一的例外是 Authentication 资源,其方法名称为 auth
(因为 authentication
太长了)。
示例
// Get a user by ID $user = $okta->user->get('jpinkerton'); // Add user to a group $group = $okta->group->addUser($someGroupId, $user->id); // Get a user's apps $userApps = $okta->user->apps($user->id);
异常处理
use Okta; try { $user = $okta->user->get('jpinkerton'); } catch (Okta\Exception as $e) { return $e->getErrorSummary(); }
请参阅文档了解可用的异常方法。
贡献
-
在 仓库 上分叉
-
克隆您的分叉
git clone git@github.com:your-username/oktasdk-php.git # NOTE: Be sure to use your fork's repository URL
-
在您的本地副本中,创建一个分支
git checkout -b descriptive-branch-name'
-
进行更改
-
提交更改
git commit -m "Your commit notes here" # NOTE: Be descriptive with your commit notes
-
推送您的分支
git push origin descriptive-branch-name
版权
此项目根据 MIT 许可证 许可。