The Python SDK has helpful custom config that you can set for a variety of use cases.
In order to set up configuration for basic proxy with the Python SDK, simply specify the proxy address for the Proxy.URL
field.
from boxsdk.config import Proxy
Proxy.URL = 'http://example-proxy-address.com'
The Python SDK also lets you set an authenticated proxy. To do this, specify the user
and password
fields and pass set that on the Proxy.AUTH
field.
from boxsdk.config import Proxy
Proxy.AUTH = {
'user': 'test_user',
'password': 'test_password',
}
The default base URL used for making API calls to Box can be changed by setting the value of the API.BASE_API_URL
field.
from boxsdk.config import API
API.BASE_API_URL = 'https://new-base-url.com'
The default URLs used to authorize a user and obtain OAuth2 authorization tokens can be modified by overwriting
API.OAUTH2_API_URL
and API.OAUTH2_AUTHORIZE_URL
constants.
from boxsdk.config import API
API.OAUTH2_API_URL = 'https://my-company.com/oauth2'
API.OAUTH2_AUTHORIZE_URL = 'https://my-company.com/authorize'
The default URL used when uploading files to Box can be changed by assigning a new value to the API.UPLOAD_URL
field.
If this variable is ever changed from default value, the SDK will alwayse use this URL to upload files to Box,
even if use_upload_session_urls
is set to True
while creating an upload session for a chunked upload.
from boxsdk.config import API
API.UPLOAD_URL = 'https://my-company-upload-url.com'
The default maximum number of retries in case of failed API call is 5 (usually 202, 429 and >= 500 response codes are retried).
To change this number you can set API.MAX_RETRY_ATTEMPTS
field.
from boxsdk.config import API
API.MAX_RETRY_ATTEMPTS = 6