dakkusingh/oktasdk

PHP client library for the Okta API (v1)

1.2.12 2018-09-18 12:36 UTC

README

Latest Stable Version Total Downloads License Build Status

PHP client library for the Okta API (v1)

Refer to the full Okta API documentation for more complete information on each resource/component.

Install with Composer

composer require dakkusingh/oktasdk

Initializing the Client

To initialize the client object you must pass in your Okta organization subdomain and API key as parameters. For example, if your Okta domain is https://foo.okta.com, your org prefix is foo. For instructions on how to get an API key for your organization, see Obtaining a token.

Example:

use Okta;

$okta = new Okta\Client('foo', 'api_key');

You may also optionally pass an array of config options as the third argument:

$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'
    ]
]);

Usage

All Okta resources are available via the $okta->$resource->$method syntax where $resource is the lower case, singular name of the resource (i.e. - Users = user, Groups = group, etc.) and $method is the method name (see the docs for all available methods). The only exception being the Authentication resource for which the method name is auth (because authentication is just too long).

Example:

// 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);

Handling Exceptions

use Okta;

try {
    $user = $okta->user->get('jpinkerton');
} catch (Okta\Exception as $e) {
    return $e->getErrorSummary();
}

See documentation for available exception methods.

Contributing

  1. Fork the repository

  2. Clone your fork:

    git clone git@github.com:your-username/oktasdk-php.git
    # NOTE: Be sure to use your fork's repository URL
  3. In your local copy, create a branch:

    git checkout -b descriptive-branch-name'
  4. Make your changes

  5. Commit your changes:

    git commit -m "Your commit notes here"
    # NOTE: Be descriptive with your commit notes
  6. Push your branch:

    git push origin descriptive-branch-name
  7. Open a Pull Request on GitHub.

Copyright

This project is liscensed under the MIT License.