Hi @katok
Assuming that the FileMaker
is the service user associated to the app, and you want to collaborate
a folder owned by some other user,.
For simplicity lets call the folder you want to share externally folder_to_share
, the owner of this folder owner
, and the service user FileMaker
, you have 3 options:
-
In the folder_to_share
add FileMaker
as a collaborator - This seems to be the situation you have on your screenshot. Those blue folders seem to have been shared with the service user. From that point on the service client can access/see the folder_to_share
. This manual sharing of folder might be harder to achieve.
-
Use the CCG to get a client (SDK) or login with the owner
user - This depends on how your application is set up, but the CCG credentials can be used to impersonate any user.
-
Use the as-user
header or get a as-user
client (SDK) - This also depends on how your application is set up, but it will allow the service user to act on behalf of the owner
user.
For the last 2 options to work your application must be set up with these options respectively:
If you choose the first option it might be challenging to find out which one is the service user, but you can make a call to the user.me
end point to get the details.
For example using the API with an authenticated CCG service user:
curl --location 'https://api.box.com/2.0/users/me?fields=id%2Ctype%2Cname%2Clogin' \
--header 'Authorization: Bearer 7O...X5'
Results in:
{
"type": "user",
"id": "20706451735",
"name": "CCG",
"login": "AutomationUser_1803368_9rbDFPFJSf@boxdevedition.com"
}
You can use the login to create the collaboration from the owner
side.
The other 2 options are a bit harder to demonstrate, so please bear with me.
I have a normal user logged in, obtained with the /users/me
:
{
"type": "user",
"id": "18622116055",
"name": "Rui Barbosa",
"login": "barduinor@gmail.com"
}
And that user (Rui) owns this folder: 165803865043
curl --location 'https://api.box.com/2.0/folders/165803865043?fields=id%2Ctype%2Cname' \
--header 'Authorization: Bearer YN...z0'
Result:
{
"type": "folder",
"id": "165803865043",
"etag": "0",
"name": "Preview Samples"
}
However if I switch back to my CCG user, the CCG user can’t:
curl --location 'https://api.box.com/2.0/folders/165803865043?fields=id%2Ctype%2Cname' \
--header 'Authorization: Bearer 7O...X5'
Result:
{
"type": "error",
"status": 404,
"code": "not_found",
"context_info": {
"errors": [
{
"reason": "invalid_parameter",
"name": "item",
"message": "Invalid value 'd_165803865043'. 'item' with value 'd_165803865043' not found"
}
]
},
"help_url": "http://developers.box.com/docs/#errors",
"message": "Not Found",
"request_id": "wzr1cmhjykdlzvvk"
}
For Option 3, I pass the as-user
header pointing to Rui user id:
curl --location 'https://api.box.com/2.0/folders/165803865043?fields=id%2Ctype%2Cname' \
--header 'as-user: 18622116055' \
--header 'Authorization: Bearer 7O..X5'
Notice it is using the same access token, resulting in:
{
"type": "folder",
"id": "165803865043",
"etag": "0",
"name": "Preview Samples"
}
Option 2 means I get an access token using the CCG client_id
and client_secret
, user
on the box_subject_type
, and Rui user id in the box_subject_id
Now I’m effectively logged in as Rui but using the CCG credentials:
curl --location 'https://api.box.com/2.0/folders/165803865043?fields=id%2Ctype%2Cname' \
--header 'Authorization: Bearer iA...9R'
Notice the different access token:
{
"type": "folder",
"id": "165803865043",
"etag": "0",
"name": "Preview Samples"
}
Let us know if this helps, and which of these options is adequate to your app.
Cheers