How to use OAuth2 client_secret, client_id in API Upload File?
AnsweredHello, i'm using the Box api for upload a file to my space, when i use the Developer Token i can success upload my file but when i use the token that i generate using the OAuth2 i get a parentId "not found" error, so, how is the correct way that i should use the OAuth2 token?
Note:
- When i use my developer token i send the parent Id = 0, (root folder of Box space), works fine.
- When i try to send the file using the OAuth2 token i already tryed it with parentId = 0 and also one of the Ids of my folders but i obtain the already explained error result
- The way i´m requesting the OAuth2 token is with the clientId, clienteSecret and grant_type = client_credentials
-
Official comment
Hello,
If you're authenticating with the client credentials grant type the default token is going to be associated with the app's service account. Whereas a developer token is associated with the user who's logged into the developer console when the button is clicked. Therefore, you have a few options for how to solve this:
- Obtain a token for your user instead of the service account. This is done by: setting
box_subject_type
touser
settingbox_subject_id
to your own user ID. - Collaborate the service account user email address (AutomationUser_xxxx_xxxxx@boxdevedition.com) on the content it needs to be able to access. To get the email address of this user I would make a call to the get current user endpoint.
Best,
Kourtney
Comment actions - Obtain a token for your user instead of the service account. This is done by: setting
-
Hello @Kourtney i try to pass my: clientId + clientSecret + box_subject_type = user and box_subject_id = (my_box_developerConsole_client_id) but it did not works, the Box reponse was:
{
"error": "unauthorized_client",
"error_description": "The \"box_subject_type\" value is unauthorized for this client_id"
}sorry but, what i'm doing wrong?
-
Hello and good morning, @Kourtney i will create other Custom App please help me to configure it from zero, i want to ble able to get a token to access box just using the clientID and the clientSecret, of course, if its is possible.
I know that when i create a custom App, first, i need to pick the Auth method what i need to select? and whats next after this?
Please sign in to leave a comment.
Comments
5 comments