REST API information for PPSK related settings?
I am currently managing two networks at work, one is using an OC300 controller (firmware 5.7.6) and the other is using the desktop version of Omada (firmware 5.9.9) running on Windows Server 2022.
I started experimenting with PPSK and found it to be extremely useful, however one thing I don't like is having to manually import lists of updated users and passwords if I ever need to make a change. I know there is documentation online for the Omada API, however the latest version I could find was for Omada v5.4.6 and it doesn't have any information pertaining to PPSK profiles and what not.
Does anyone have any information about workarounds regarding PPSK and API calls, or if there is updated documentation?
Thanks in advance.
- Copy Link
- Subscribe
- Bookmark
- Report Inappropriate Content
@d0ugmac1 Here's a quick explanation of my setup:
- Using OC300 with version 5.7.6.
- OMADA_URL: The URL of your Omada controller. For this script, mine is "https://10.1.1.2:443".
- USERNAME: The username you use to log into the controller. For this script, mine is "admin".
- PASSWORD: The password you use to log into the controller. For this script, mine is "Password123".
- CONTROLLER_ID: The ID of your Omada controller. The script will automatically pull this information.
- TOKEN: Generates and saves a token/cookies that validates the session. The script will automatically configure this part.
- SITE: Usually set to "default". This is used to grab the site ID of the site you want to configure. For this script, mine is "default".
NOTE: Sometimes setting this to "default" doesn't work as the site may not be configured as the default site. I ran into this problem on one of my controllers (version 5.9.9), and as far as I know, there is no way to configure a site as the default site. If anyone has figured out how to do this, please let me know. For now, it is fairly easy to manually set this variable as the site ID is visible in API calls when examining with Chrome for example. For more info about this, please let me know.
- SITE_ID: The ID of the site you want to configure. The script will automatically pull this information for the "default" site.
- PPSK_ID: The ID of the PPSK profile you want to configure. The script will automatically pull this information for the first profile in the GET request.
NOTE: This will only work as intended if you have just one existing profile. If you have more than one PPSK profile, you need to modify the command so that you filter the results to the correct ID. Alternatively, you can also set the ID manually.
#!/bin/bash
OMADA_URL="https://10.1.1.2:443"
USERNAME="admin"
PASSWORD="Password123"
CONTROLLER_ID="$(curl -sk "${OMADA_URL}/api/info" | jq -r .result.omadacId)"
TOKEN="$(curl -sk -X POST -c "/tmp/omada-cookies.txt" -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/login" -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' | jq -r .result.token)"
SITE="default"
SITE_ID="$(curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE}" | jq -r .result.id)"
PPSK_ID="$(curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk" | jq -r .result[].id)"
curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk/${PPSK_ID}" | jq .
RESPONSE:
{
"errorCode": 0,
"msg": "Success.",
"result": {
"id": "642e4015147a237c46d056f3",
"profileName": "Rooms",
"ppsk": [
{
"name": "LAN",
"psk": "testing100"
}
]
}
}
To add or modify entries in the PPSK profile, replace the last line with this one:
curl -sk -X POST -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk/${PPSK_ID}" -d '{"profileName":"Rooms","ppsk":[{"name":"AlexWPA2Pass","psk":"Pass-For-Alex","mac":""},{"name":"test2","psk":"another-test","mac":""}]}' | jq .
Where "profileName" is the name of the PPSK profile, "ppsk" is the array of entries, "name" is the name given to an entry, "psk" is the password.you can set, and "mac" is optional.
RESPONSE:
{
"errorCode": 0,
"msg": "Success."
}
NOTE: Using curl POST command will replace any existing PPSK entries! If you do not want to remove any PPSK, but instead modify or add new entries, with POST you must include the entires in every POST! Example: Let's say you have 3 entries, and need to modify entires 1 and 2. If you don't include the third entry in the POST (even if you haven't made any changes to it), it will be removed from the PPSK profile! I haven't had time to experiment other methods, however the API documentation shows the PATCH command used for some API calls. Maybe there is a way to use PATCH when editing PPSK entries, that way you don't have to keep adding existing entries to the POST command.
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
@Hank21 Thanks! Unfortunately, I couldn't find what I needed in this documentation as it doesn't specify the request path or parameters for adding/modifying PPSK profiles. However, I eventually figured it out myself!
If anyone is interested, I'd be glad to share a simple bash script I made to test adding/modifying PPSK entries in the Omada controller.
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
@d0ugmac1 Here's a quick explanation of my setup:
- Using OC300 with version 5.7.6.
- OMADA_URL: The URL of your Omada controller. For this script, mine is "https://10.1.1.2:443".
- USERNAME: The username you use to log into the controller. For this script, mine is "admin".
- PASSWORD: The password you use to log into the controller. For this script, mine is "Password123".
- CONTROLLER_ID: The ID of your Omada controller. The script will automatically pull this information.
- TOKEN: Generates and saves a token/cookies that validates the session. The script will automatically configure this part.
- SITE: Usually set to "default". This is used to grab the site ID of the site you want to configure. For this script, mine is "default".
NOTE: Sometimes setting this to "default" doesn't work as the site may not be configured as the default site. I ran into this problem on one of my controllers (version 5.9.9), and as far as I know, there is no way to configure a site as the default site. If anyone has figured out how to do this, please let me know. For now, it is fairly easy to manually set this variable as the site ID is visible in API calls when examining with Chrome for example. For more info about this, please let me know.
- SITE_ID: The ID of the site you want to configure. The script will automatically pull this information for the "default" site.
- PPSK_ID: The ID of the PPSK profile you want to configure. The script will automatically pull this information for the first profile in the GET request.
NOTE: This will only work as intended if you have just one existing profile. If you have more than one PPSK profile, you need to modify the command so that you filter the results to the correct ID. Alternatively, you can also set the ID manually.
#!/bin/bash
OMADA_URL="https://10.1.1.2:443"
USERNAME="admin"
PASSWORD="Password123"
CONTROLLER_ID="$(curl -sk "${OMADA_URL}/api/info" | jq -r .result.omadacId)"
TOKEN="$(curl -sk -X POST -c "/tmp/omada-cookies.txt" -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/login" -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' | jq -r .result.token)"
SITE="default"
SITE_ID="$(curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE}" | jq -r .result.id)"
PPSK_ID="$(curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk" | jq -r .result[].id)"
curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk/${PPSK_ID}" | jq .
RESPONSE:
{
"errorCode": 0,
"msg": "Success.",
"result": {
"id": "642e4015147a237c46d056f3",
"profileName": "Rooms",
"ppsk": [
{
"name": "LAN",
"psk": "testing100"
}
]
}
}
To add or modify entries in the PPSK profile, replace the last line with this one:
curl -sk -X POST -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/sites/${SITE_ID}/setting/profiles/ppsk/${PPSK_ID}" -d '{"profileName":"Rooms","ppsk":[{"name":"AlexWPA2Pass","psk":"Pass-For-Alex","mac":""},{"name":"test2","psk":"another-test","mac":""}]}' | jq .
Where "profileName" is the name of the PPSK profile, "ppsk" is the array of entries, "name" is the name given to an entry, "psk" is the password.you can set, and "mac" is optional.
RESPONSE:
{
"errorCode": 0,
"msg": "Success."
}
NOTE: Using curl POST command will replace any existing PPSK entries! If you do not want to remove any PPSK, but instead modify or add new entries, with POST you must include the entires in every POST! Example: Let's say you have 3 entries, and need to modify entires 1 and 2. If you don't include the third entry in the POST (even if you haven't made any changes to it), it will be removed from the PPSK profile! I haven't had time to experiment other methods, however the API documentation shows the PATCH command used for some API calls. Maybe there is a way to use PATCH when editing PPSK entries, that way you don't have to keep adding existing entries to the POST command.
- Copy Link
- Report Inappropriate Content
Information
Helpful: 0
Views: 873
Replies: 4
Voters 0
No one has voted for it yet.