I am using a request session with oauth2 authentication. Everything works fine when I upload small files, but for a 4 GB file I get an error with an expired token, it looks like the file was downloaded, but in the final session the partial token was confirmed again.
Is there a chance to deal with this situation? Upload a large file with a token updated before the session closes, or something else?
sample code below, thanks for any help. Hooray!
import requests from io import StringIO from requests_toolbelt.multipart.encoder import MultipartEncoder TOKEN_PAYLOAD = { 'grant_type': 'password', 'client_id': '###', 'client_secret': '###', 'username': '###', 'password': '####' } def get_token(): response = requests.post( 'https://oauth/token', params=TOKEN_PAYLOAD) response_data = response.json() token = response_data.get('access_token') return token
source share