Here is the code
from boxsdk import OAuth2, Client
CLIENT_ID = 'XXXXXXXXXXXXXXXXXXX'
CLIENT_SECRET = 'XXXXXXXXXXXXXXXXXX'
oauth2 = OAuth2(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
)
access_token = oauth2.access_token
client = Client(oauth2)
folder_id = '1234'
folder = client.folder(folder_id=folder_id).get()
file_path = "C:\\Users\\sample.txt"
file_name = 'sample.txt'
with open(file_path, 'rb') as f:
file_uploaded = folder.upload_stream(f, file_name)
print(f'File {file_uploaded.name} uploaded successfully to {folder.name} folder.')
Error
boxsdk.exception.BoxOAuthException:
Message: No "refresh_token" parameter found
Status: 400
URL: https://api.box.com/oauth2/token
Method: POST