dakkusingh/oktasdk

Okta API(v1)的PHP客户端库

1.2.12 2018-09-18 12:36 UTC

README

Latest Stable Version Total Downloads License Build Status

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();
}

请参阅文档了解可用的异常方法。

贡献

  1. 存储库上Fork

  2. 克隆您的Fork

    git clone git@github.com:your-username/oktasdk-php.git
    # NOTE: Be sure to use your fork's repository URL
  3. 在本地副本中,创建一个分支

    git checkout -b descriptive-branch-name'
  4. 进行更改

  5. 提交您的更改

    git commit -m "Your commit notes here"
    # NOTE: Be descriptive with your commit notes
  6. 推送您的分支

    git push origin descriptive-branch-name
  7. 在GitHub上打开一个Pull Request

版权

本项目受MIT许可证许可。