dakkusingh / oktasdk
Okta API(v1)的PHP客户端库
1.2.12
2018-09-18 12:36 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: 2024-09-19 10:21:14 UTC
README
Okta API(v1)的PHP客户端库
有关每个资源/组件的更完整信息,请参阅Okta API完整文档。
使用Composer安装
composer require dakkusingh/oktasdk
初始化客户端
要初始化客户端对象,您必须以参数形式传递您的Okta组织子域和API密钥。例如,如果您的Okta域是 https://foo.okta.com
,则您的组织前缀是 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-><资源>-><方法>
语法访问,其中$资源
是资源(例如,用户 = user
,组 = group
等)的英文单数小写名称,而$方法
是方法名称(请参阅文档了解所有可用方法)。唯一的例外是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(); }
请参阅文档了解可用的异常方法。
贡献
-
在存储库上Fork
-
克隆您的Fork
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
-
在GitHub上打开一个Pull Request。
版权
本项目受MIT许可证许可。