We have a Cordova APP that calls an API with custom security.
Now, we're migrating to IBM MFP 8.0
I've followed the steps provided in https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/protecting-external-resources/ to protect an external resource and https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/resource-request/javascript/ to call via Cordova.
The app uses the plugin cordova-plugin-file-transfer for 2 things:
- Download an image from a protected REST endpoint to the filesystem and use it in HTML (for example, the user profile photo)
- Upload an image to a protected REST endpoint (for example, upload the user profile photo from the gallery)
It worked because the plugin can send custom Headers.
How can i achieve the same functionality with a MFP protected endpoint?
Update:
The Rest API that was working, now it's been protected as an external resource by MFP using a confidential client.
The API uses a Spring Multipart for upload and produces byte[] PNG for download:
@RequestMapping(value = PROFILE_UPDATE_USER_PROFILE_PHOTO,
method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Override
public ResponseEntity<DataOutput<APIError[], ProfilePhotoOutput>> updateUserProfilePhoto(
MultipartFile file) {
return profileController.updateUserProfilePhoto(file);
}
@RequestMapping(value = PROFILE_GET_USER_PROFILE_PHOTO,
method = RequestMethod.GET, produces = {MediaType.IMAGE_GIF_VALUE, MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
@ResponseBody
@Override
public ResponseEntity<byte[]> getUserProfilePhoto() {
return profileController.getUserProfilePhoto();
}