Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)TW
Twissell @community.nodebb.org
Posts 1
Comments 1

Creaty user(s) via Python3 and API calls

Hello everyone!

I want to create some user programmatically using simple Python script and Master API token I've written this test script

``` #!/usr/bin/python3

import sys import requests

auth_url = 'https://forum.example.com/api/v3/utilities/login' #config_url = 'https://forum.example.com/api/config' main_url = 'https://forum.example.com/api/v3/users/'

headers = {'Authorization':'Bearer Token-is-here'} auth_data = {'username':'John','password':'JohnPassword','email':'john@example.com'}

#Authenticate before using API r = requests.post(auth_url,headers=headers,data=auth_data)

#Get config with user data #r = requests.get(config_url) #res_json = r.json(); #csrf_key = res.json['csrf_token'] main_data = {'username':'Robin93', 'password':'MyPassword', 'email':'robin@example.com'} r = requests.post(main_url, data=main_data) ``` But I get r.text '{"status":{"code":"forbidden","message":"You are not authorised to make this call"},"response":{}}' in response :-( What am I doing the wrong way?

Thank you all !

P.S. My token is Master Token, so I updated the original code snippet.

1