box / box-python-sdk

Box SDK for Python
http://opensource.box.com/box-python-sdk/
Apache License 2.0
419 stars 215 forks source link

403 Error: No content or content unavailable for logging #857

Closed AgazW closed 11 months ago

AgazW commented 11 months ago

Description of the Issue

Following is my code to access content (which I uploaded) on my Box account. I'm not the box admin; I have Editor privileges on other content on the box.

Code to access the box

from boxsdk import OAuth2, Client
import sys

TOKEN = 'mytoken'
CLIENT_ID = 'myid'
CLIENT_SECRET = 'clientsecret'

auth = OAuth2(client_id=CLIENT_ID, 
client_secret=CLIENT_SECRET, 
access_token=TOKEN
)
box = Client(auth)

me = box.user().get()
print("logged in to Box as", me.login)
print(me.response_object)

file_id = ''
file_info = box.file(file_id).get()
print(file_info)
print(f'File "{file_info.name}" has a size of {file_info.size} bytes')

It prints the output : File "Targeted Protein Accession.csv" has a size of 423 bytes

But when I try to read the content of the file

file_content = box.file(file_id).content()

Error Message, Including Stack Trace

Screenshot 2023-11-03 at 11 36 53 AM
congminh1254 commented 11 months ago

Hi @AgazW

Thanks for submitting this issue to us. To double check this issue, can you just make a simple REST request as here

If the request successfully with REST API but failed on SDK, we will dive deeper to investigate, but if you also got 403 error when sending request manually, you can contact Box Support to figure out what is wrong with this request.

I am looking forward for your answer.

Best, Minh

AgazW commented 11 months ago

@congminh1254 Thank you for your prompt response. I get the following:

HTTP/2 403 
date: Fri, 03 Nov 2023 19:33:49 GMT
content-type: application/json
x-envoy-upstream-service-time: 154
box-request-id: 0a3c3771b10b38e4a446b1849bbef5bc6
cache-control: no-cache, no-store
strict-transport-security: max-age=31536000
via: 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

{"type":"error","status":403,"code":"access_denied_insufficient_permissions","help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Access denied - insufficient permission","request_id":"zil2ohjij5i2da7"}%   
congminh1254 commented 11 months ago

So it's not SDK issue, you can double check about your permission on this file, or take a look at this issue box/box-java-sdk#48.

If the issue persist, you can also contact the Box Support and they will help you understand what's wrong with this file.

AgazW commented 10 months ago

Thank you very much for the information.