{"id":49434250,"url":"https://github.com/cloudbeds/okta-sdk-php","last_synced_at":"2026-04-29T16:03:51.512Z","repository":{"id":50322602,"uuid":"395277228","full_name":"cloudbeds/okta-sdk-php","owner":"cloudbeds","description":"PHP SDK for the Okta API","archived":false,"fork":true,"pushed_at":"2026-04-22T17:54:40.000Z","size":733,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-04-22T19:29:39.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Nchalenko/okta-sdk-php","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudbeds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-12T10:15:15.000Z","updated_at":"2024-10-24T18:26:26.000Z","dependencies_parsed_at":"2023-01-23T10:48:55.081Z","dependency_job_id":null,"html_url":"https://github.com/cloudbeds/okta-sdk-php","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/cloudbeds/okta-sdk-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudbeds%2Fokta-sdk-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudbeds%2Fokta-sdk-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudbeds%2Fokta-sdk-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudbeds%2Fokta-sdk-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudbeds","download_url":"https://codeload.github.com/cloudbeds/okta-sdk-php/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudbeds%2Fokta-sdk-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32432917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-29T16:03:50.169Z","updated_at":"2026-04-29T16:03:51.504Z","avatar_url":"https://github.com/cloudbeds.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Okta PHP SDK\n\n[![Build Status](https://api.travis-ci.org/okta/okta-sdk-php.svg?branch=master,develop)](https://travis-ci.org/okta/okta-sdk-php)\n[![Codecov](https://img.shields.io/codecov/c/github/okta/okta-sdk-php.svg)](https://codecov.io/github/okta/okta-sdk-php)\n[![License](https://poser.pugx.org/okta/sdk/license.svg)](https://packagist.org/packages/okta/sdk)\n[![Support](https://img.shields.io/badge/support-Developer%20Forum-blue.svg)](https://devforum.okta.com/)\n\n## Installation\n**okta-sdk-php** is available on Packagist as the [okta/sdk](http://packagist.org/packages/okta/sdk) package.\n\nRun `composer require okta/sdk` from the root of your project in terminal, and you are done.\n\n## Client Initialization\nOnce you have the SDK installed in your project, you will need to instantiate a Client object. We follow the builder\npattern for building a Client. You can create a Client by calling the ClientBuilder and relying on the ~/.okta/okta\n.yaml file for the settings\n\n```php\n$client = (new \\Okta\\ClientBuilder())\n            -\u003ebuild();\n```\n\nBy default, The client builder will look for a file in your home directory with the Okta properties you want to use.\nThis file should be placed at  `~/.okta/okta.yaml`. If at this location, you do not need to define the location\nduring initialization. If you are unable to place the file there, or you are on a Windows based machine, you will\nhave to define the location of this file manually if you want to use the file.\n\n```php\n$client = (new \\Okta\\ClientBuilder())\n            -\u003esetConfigFileLocation('path/to/okta.yaml')\n            -\u003ebuild();\n```\n\nIf you need to override any of the defaults from your `~/.okta/okta.yaml` file, or you do not have one, you can set\nthe properties on the client builder directly. The minimum required properties are your token and organization url.\n\n```php\n$client = (new \\Okta\\ClientBuilder())\n            -\u003esetToken('YourApiToken')\n            -\u003esetOrganizationUrl('https://dev-123456.oktapreview.com')\n            -\u003ebuild();\n```\n\n### Changing your Http Client Instance\nThe Okta PHP SDK follows PSR-7 standards for HTTP Messages. We are using Httplug which allows you to change out to\nany PSR-7 compliant Http Client. Create a new instance of a `Http\\Client\\HttpClient`\nimplementation and pass it into the client builder.\n\n```php\n$client = (new \\Okta\\ClientBuilder())\n            -\u003esetHttpClient(new Http\\Client\\HttpClient())\n            -\u003ebuild();\n```\n\n### OAuth 2.0\n\nOkta allows you to interact with Okta APIs using scoped OAuth 2.0 access tokens. Each access token enables the bearer to perform specific actions on specific Okta endpoints, with that ability controlled by which scopes the access token contains.\n\nThis SDK supports this feature only for service-to-service applications. Check out [our guides](https://developer.okta.com/docs/guides/implement-oauth-for-okta-serviceapp/overview/) to learn more about how to register a new service application using a private and public key pair.\n\nWhen using this approach you won't need an API Token because the SDK will request an access token for you. In order to use OAuth 2.0, construct a client instance by passing the following parameters:\n\n```php\n$client = (new \\Okta\\ClientBuilder)\n            -\u003esetAuthorizationMode(new \\Okta\\Utilities\\AuthorizationMode(\\Okta\\Utilities\\AuthorizationMode::PRIVATE_KEY))\n            -\u003esetClientId({{clientId}})\n            -\u003esetScopes(\"okta.users.read okta.apps.read\")\n            -\u003esetPrivateKey(\"{{PEM PRIVATE KEY BLOCK}}\")\n            -\u003ebuild();\n```\n\n\n## Users\n### Finding a user by id\n```php\n$user = new \\Okta\\Users\\User();\n$foundUser = $user-\u003eget('00uak5dkxjhg4AQ230h7');\ndump($foundUser);\n```\n\n### Finding a user by email\n```php\n$user = new \\Okta\\Users\\User();\n$foundUser = $user-\u003eget('email@example.com');\ndump($foundUser);\n```\n\n### Creating a User\n```php\n$user = new \\Okta\\Users\\User();\n$profile = new \\Okta\\Users\\UserProfile();\n\n$profile-\u003esetFirstName('John')\n    -\u003esetLastName('User')\n    -\u003esetLogin('auser@example.com')\n    -\u003esetEmail('auser@example.com');\n$user-\u003esetProfile($profile);\n\n$credentials = new \\Okta\\Users\\UserCredentials();\n\n$password = new \\Okta\\Users\\PasswordCredential();\n$password-\u003esetValue('Abcd1234!');\n\n$recoveryQuestion = new \\Okta\\Users\\RecoveryQuestionCredential();\n$recoveryQuestion-\u003esetQuestion('What Language do I write in?')\n    -\u003esetAnswer('PHP!');\n\n\n$provider = new \\Okta\\Users\\AuthenticationProvider();\n$provider-\u003esetName('OKTA')\n    -\u003esetType('OKTA');\n\n\n$credentials-\u003esetPassword($password);\n$credentials-\u003esetRecoveryQuestion($recoveryQuestion);\n$credentials-\u003esetProvider($provider);\n\n\n$user-\u003esetCredentials($credentials);\n\n\n$user-\u003ecreate();\n```\n\n### Update user profile\nOur SDK allows you to fill in the default profile fields, as well as other dynamic fields that you create in your\nprofile.\n\n```php\n$user = new \\Okta\\Users\\User();\n$foundUser = $user-\u003eget('00unz7r7oRzov7Hm55d6');\n$profile = $foundUser-\u003egetProfile();\n$profile-\u003emiddleName = 'Middle Name';\n$foundUser-\u003esetProfile($profile);\n$foundUser-\u003esave();\n```\n\n## Pagination and Collections\nAll of our calls that return a set of items will return a Collection object. The collection object we built on top of\n is the tightenco/collect object.\n\n### Getting all users\n```php\n$users = (new \\Okta\\Okta)-\u003egetUsers();\n\n// get the first user in the collection\n$firstUser = $users-\u003efirst();\n```\n\n### Narrowing Responses\nTo start at the second entry and get the next two items:\n```php\n$users = (new \\Okta\\Okta)-\u003egetUsers(['query' =\u003e ['limit' =\u003e 2, 'after' =\u003e 2]]);\n```\n\n## Caching\nThe Okta PHP SDK allows any resource with a self link to be cached by default. The SDK uses any PSR-6\ncaching adaptor that you would like to use. By default, we ship with the\n[filesystem cache pool](https://github.com/php-cache/filesystem-adapter) with the\n[flysystem memory adaptor](https://github.com/thephpleague/flysystem-memory).  By doing this, there is no\nneed to configure anything, however, if you would like to run with your own Cache strategy, or change how\nthe default works, you are able to swap out the Cache Manager. Create a new Cache Manager that extends the\nbase `\\Okta\\Cache\\CacheManager` class, and call the parent `setCachePool()` method. This should be called\nwith an instance of a PSR-6 compliant cache pool implementation.  Once created, you can swap out the manager\nusing the `ClientBuilder` class\n\n```php\n$clientBuilder = new ClientBuilder();\n        $clientBuilder-\u003esetCacheManager(new MyCacheManager());\n        $client = $clientBuilder-\u003ebuild();\n```\n\n### Contents of the okta.yaml File\n```yaml\nokta:\n  client:\n    orgUrl: \"https://{yourOktaDomain}\"\n    token: \"{token}\"\n```\n\nWhen you use OAuth 2.0 the full YAML configuration looks like:\n\n```yaml\nokta:\n  client:\n    connectionTimeout: 30 # seconds\n    orgUrl: \"https://{yourOktaDomain}\"\n    proxy:\n      port: null\n      host: null\n      username: null\n      password: null\n    authorizationMode: \"PrivateKey\"\n    clientId: \"{yourClientId}\"\n    Scopes:\n      - scope.1\n      - scope.2\n    PrivateKey: \"{PEM PRIVATE KEY}\"\n    requestTimeout: 0 # seconds\n    rateLimit:\n      maxRetries: 4\n```\n\n\u003e You can pass the path to your private key pem file as well instead of copying the pem string into the YAML configuration\n\u003e E.g `PrivateKey: /Path/to/privateKey.pem`\n\nFor information on what can go into the query property, visit\n[our documentation](https://developer.okta.com/docs/api/resources/users.html#list-users)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudbeds%2Fokta-sdk-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudbeds%2Fokta-sdk-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudbeds%2Fokta-sdk-php/lists"}