Skip to content

Commit 4ab73a2

Browse files
committed
- Updated the README.md.
1 parent 998554a commit 4ab73a2

1 file changed

Lines changed: 46 additions & 39 deletions

File tree

README.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ Python 3.7+
1616
## Installation & Usage
1717
### pip install
1818

19-
If the python package is hosted on a repository, you can install directly using:
19+
If the repository is cloned, you can install directly using the below command at root directory (where `setup.py` is located):
2020

2121
```sh
22-
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
22+
pip install -e .
2323
```
24-
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
2524

2625
Then import the package:
2726
```python
@@ -52,45 +51,53 @@ Please follow the [installation procedure](#installation--usage) and then run th
5251

5352
```python
5453

55-
import okta
56-
from okta.rest import ApiException
57-
from pprint import pprint
58-
59-
# Defining the host is optional and defaults to https://subdomain.okta.com
60-
# See configuration.py for a list of all supported configuration parameters.
61-
configuration = okta.Configuration(
62-
host = "https://subdomain.okta.com"
63-
)
64-
65-
# The client must configure the authentication and authorization parameters
66-
# in accordance with the API server security policy.
67-
# Examples for each auth method are provided below, use the example that
68-
# satisfies your auth use case.
69-
70-
# Configure API key authorization: apiToken
71-
configuration.api_key['apiToken'] = os.environ["API_KEY"]
72-
73-
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
74-
# configuration.api_key_prefix['apiToken'] = 'Bearer'
75-
76-
configuration.access_token = os.environ["ACCESS_TOKEN"]
77-
54+
import asyncio
55+
from okta import UserProfile, PasswordCredential, CreateUserRequest, UserNextLogin, UserCredentials
56+
from okta.client import Client as OktaClient
57+
config = {
58+
'orgUrl': 'https://{your_org}.okta.com',
59+
'token': 'YOUR_API_TOKEN',
60+
}
7861

79-
# Enter a context with an instance of the API client
80-
with okta.ApiClient(configuration) as api_client:
81-
# Create an instance of the API class
82-
api_instance = okta.AgentPoolsApi(api_client)
83-
pool_id = 'pool_id_example' # str | Id of the agent pool for which the settings will apply
84-
update_id = 'update_id_example' # str | Id of the update
62+
okta_client = OktaClient(config)
63+
user_config = {
64+
"firstName": "Sample",
65+
"lastName": "Sample",
66+
"email": "sample12.sample@example.com",
67+
"login": "sample12.sample@example.com",
68+
"mobilePhone": "555-415-1337"
69+
}
70+
user_profile = UserProfile(**user_config)
8571

86-
try:
87-
# Activate an Agent Pool update
88-
api_response = api_instance.activate_agent_pools_update(pool_id, update_id)
89-
print("The response of AgentPoolsApi->activate_agent_pools_update:\n")
90-
pprint(api_response)
91-
except ApiException as e:
92-
print("Exception when calling AgentPoolsApi->activate_agent_pools_update: %s\n" % e)
72+
password_value = {
73+
"value": "Knock*knock*neo*111"
74+
}
75+
password_credential = PasswordCredential(**password_value)
76+
user_credentials = {
77+
"password": password_credential
78+
}
79+
user_credentials = UserCredentials(**user_credentials)
80+
create_user_request = {
81+
"profile": user_profile,
82+
"credentials": user_credentials,
83+
}
84+
user_request = CreateUserRequest(**create_user_request)
85+
async def users():
86+
next_login = UserNextLogin(UserNextLogin.CHANGEPASSWORD)
87+
user, resp, err = await okta_client.create_user(user_request, activate=True, provider=False, next_login=next_login)
88+
print("The response of UserApi->create_user:\n")
89+
print(user)
90+
print(resp, err)
9391

92+
users, resp, err = await okta_client.list_users()
93+
for user in users:
94+
print(user.profile.first_name, user.profile.last_name)
95+
try:
96+
print(user.profile.customAttr)
97+
except:
98+
print('User has no customAttr')
99+
loop = asyncio.get_event_loop()
100+
loop.run_until_complete(users())
94101
```
95102

96103
## Documentation for API Endpoints

0 commit comments

Comments
 (0)