Get User Image
Retrieve the profile image for a user.
GET https://instance.securid.com/aveksa/command.submit?cmd=getUserImage
note
When called with a trusted application token and no userId, the image for the trusted app user is returned.
When no image has been set for the specified user, the response is 200 with an empty JSON body (not an error).
Request
Parameters
| getUserImage | |
| userId | The numeric ID of the user. If omitted, the image for the trusted app user is returned. |
Headers
Bearer token | |
| Accept | application/json |
| Content-Type | application/json |
Response
When an image exists, the response body is a binary PNG and Content-Type is image/png.
When no image is set (or the user does not exist), the response is 200 with the following JSON body:
{
"data": {
"type": "getUserImage"
}
}
Examples
Request
- Curl
- Python
- Node.js
curl -K -X GET \
"https://instance.securid.com/aveksa/command.submit?cmd=getUserImage&format=json&userId=<user-id>" \
-H "Authorization: Bearer <token>" \
-o user.png
import requests
url = "https://instance.securid.com/aveksa/command.submit"
params = {
"cmd": "getUserImage",
"format": "json",
"userId": "<user-id>"
}
headers = {
'Authorization': 'Bearer <token>'
}
response = requests.get(url, params=params, headers=headers)
if response.status_code == 200:
content_type = response.headers.get('Content-Type', '')
if 'image/png' in content_type:
with open('user.png', 'wb') as f:
f.write(response.content)
print("Image saved to 'user.png'")
else:
print("No image set for this user:", response.json())
else:
print(f"Request failed with status code {response.status_code}")
const axios = require('axios');
const fs = require('fs');
const url = "https://instance.securid.com/aveksa/command.submit";
const params = {
cmd: "getUserImage",
format: "json",
userId: "<user-id>"
};
const headers = {
'Authorization': 'Bearer <token>'
};
axios.get(url, { params, headers, responseType: 'arraybuffer' })
.then(response => {
if (response.status === 200) {
const contentType = response.headers['content-type'] || '';
if (contentType.includes('image/png')) {
fs.writeFileSync('user.png', response.data);
console.log("Image saved to 'user.png'");
} else {
console.log("No image set for this user:", Buffer.from(response.data).toString('utf8'));
}
} else {
console.log(`Request failed with status code ${response.status}`);
}
})
.catch(error => {
console.error('Error:', error);
});
Response
- 200 Image
- 200 No Image
- 401 Invalid Token
The response body contains the binary PNG image data (Content-Type: image/png).
Returned when no image has been set for the user, or when the userId does not exist.
{
"data": {
"type": "getUserImage"
}
}
<html>
<head>
<title>Error</title>
</head>
<body>The token is not valid for the command 'getUserImage'. Token is invalid or expired</body>
</html>
Verified with RSA Governance & Lifecycle version 8.0.0.188886 P10_HF01.