A Python utility that creates a new user in Okta and stores their Okta credentials in 1Password, then creates a Secure Item Sharing Link for the credentials that can be sent to the new employee's personal email address.
This script streamlines the user onboarding process by:
- Collecting user information through an interactive prompt.
- Creating a new user account in Okta with a secure random password.
- Storing the new user's Okta credentials in 1Password.
- Creating a share link that allows you to securely share the Okta credentials with the new employee by sending the link to their personal email address.
- Python 3.9+
- 1Password Service Account with read, write, and share permissions in the vault where you want to store the new employee's Okta credentials.
- Okta API token with user management permissions
- Python packages:
okta-sdk-python
onepassword-sdk
pyperclip
python-dotenv
- Clone or download this repository.
- Install the required dependencies:
pip install okta-sdk-python onepassword-sdk pyperclip python-dotenv
- Create a
.env
file in the same directory as the script with the following variables:
OKTA_ORG_URL=https://your-domain.okta.com
OKTA_API_TOKEN=your-okta-api-token
OP_SERVICE_ACCOUNT_TOKEN=your-1password-service-account-token
OP_VAULT_ID=your-1password-vault-id
Run the script using Python:
op run --env-file=.env -- python create-okta-user.py
The script will:
- Prompt you for the user's information:
- Work email address (will be used as username)
- First name
- Last name
- Personal email address (for credential sharing)
- Create the user in Okta with a secure 40-character random password.
- Store the credentials in 1Password.
- Generate a share link and copy it to your clipboard.
- The share link will be valid for 14 days and can be sent to the user's personal email.
- Generates strong 40-character random passwords.
- Validates email formats before processing.
- Uses one-time share links with 14-day expiration.
- Securely stores credentials in 1Password.
- Prevents password exposure by sharing directly from 1Password.
If you encounter errors:
- Make sure all environment variables are correctly set in the
.env
file. - Verify your Okta API token has sufficient permissions.
- Check that your 1Password service account token is valid and has read, write, and share permissions in the specified vault.
- Make sure the specified 1Password vault exists and is accessible.
- The script currently only supports basic user creation.
- The script does not implement Okta Group assignments nor does it create additional Okta profile fields.
- The script pre-defines a password recipe when generating a password for a newly-created user using a fixed 40-character random password. 1Password SDKs also support arbitrary password recipes.