Skip to main content

How to create API User on Sand Box

 

# %%
import requests as rq
import json
import uuid
url = "https://sandbox.momodeveloper.mtn.com/v1_0/apiuser"
API_USER = str(uuid.uuid4())
headers = {
"X-Reference-Id": API_USER,
"Ocp-Apim-Subscription-Key": "4c91dae7a6f1474387a23a1f3d448eb7",
"Content-Type": "application/json"
}
body = {
"providerCallbackHost": "webhook.site"
}
resp = rq.request("post", url, json=body, headers=headers)
print(resp.status_code,"\n API USER Is",API_USER)



# %%
url = "https://sandbox.momodeveloper.mtn.com/v1_0/apiuser/"+API_USER+"/apikey"

headers = {
"Ocp-Apim-Subscription-Key": "4c91dae7a6f1474387a23a1f3d448eb7",
"Content-Type": "application/json"
}

resp = rq.request("post", url, headers=headers)
print(resp.status_code,"\nAPI User is ",API_USER)
jsn = resp.text.split(":")
API_KEY = str(jsnn1].replace("}","")).replace("\"","")
print("API Key is ", API_KEY)