Created
May 22, 2019 10:54
-
-
Save nicksnell/abb14df7d851cd5dcfcee9e07f61287a to your computer and use it in GitHub Desktop.
Remove a chunk of users (100) from auth0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from auth0.v3.authentication import GetToken | |
from auth0.v3.management import Auth0 | |
def main(): | |
domain = os.environ.get('AUTH0_DOMAIN') | |
client_id = os.environ.get('AUTH0_CLIENT') | |
secret = os.environ.get('AUTH0_SECRET') | |
get_token = GetToken(domain) | |
token = get_token.client_credentials( | |
client_id, | |
secret, | |
'https://{}/api/v2/'.format(domain) | |
) | |
token = token['access_token'] | |
auth0 = Auth0(domain, token) | |
#result = auth0.users.delete_all_users() | |
users = auth0.users.list(per_page=100, include_fields=False, search_engine='v3') | |
count = 0 | |
for user in users['users']: | |
print(f'- Removing {user["user_id"]}') | |
auth0.users.delete(user['user_id']) | |
time.sleep(3) | |
count += 1 | |
print(f'Done. {count}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment