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.
@razibal Yep, it really works! :-)