Skip to content

Instantly share code, notes, and snippets.

@Ashex
Created June 28, 2023 09:50
Show Gist options
  • Save Ashex/c8512ffe9bf7259e6e4488a565981acc to your computer and use it in GitHub Desktop.
Save Ashex/c8512ffe9bf7259e6e4488a565981acc to your computer and use it in GitHub Desktop.
import argparse
import requests
import json
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'token', type=str, help='Bearer token, grab it from the browser or something idk')
parser.add_argument(
'user', type=str, help='the username without the domain')
args = parser.parse_args()
user_id = lookup_user(args.user, args.token)
reset_password(user_id, args.token)
# https://calckey.social/api-doc#operation/users/search
def lookup_user(username, token):
headers = {
'Content-Type': 'application/json',
'Origin': 'https://wibblur.social',
'authorization': f'Bearer {token}'
}
payload = {
'query': username,
'offset': 0,
'limit': 1,
'origin': 'local',
'detail': True
}
r = requests.post('https://wibblur.social/api/users/search', headers=headers, data=json.dumps(payload))
return r.json()[0]['id']
# https://calckey.social/api-doc#operation/admin/reset-password
def reset_password(user_id, token):
headers = {
'Content-Type': 'application/json',
'Origin': 'https://wibblur.social',
'authorization': f'Bearer {token}'
}
payload = {
'userId': user_id
}
r = requests.post('https://wibblur.social/api/admin/reset-password', headers=headers, data=json.dumps(payload))
password = r.json()['password']
print(f'Password reset to: {password}')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment