I’m using a Seeed Studio XIAO ESP32S3 board programmed with Adafruit CircuitPython 9.2.7. I have written a very lite “SDK” to be able to issue requests to Dropbox API (V2) for a limited number of operations: (re)authentication, get_user_account, list_folder, upload_file. My code is available here https://github.com/istvanzk/xiaocam_cpy
The initial OAuth2 authorization works fine. I request "offline" access during the OAuth app authorization flow on a development machine, not the XIAO board. Then I use the received "refresh token" (stored in settings.toml) to programmatically get a new short-lived access token at any point in time, without further manual user interaction, in the code running on the XIAO board.
Problem: I'm having a strange error when sending any POST request to Dropbox API (V2) host and route, e.g. to https://api.dropboxapi.com/2/users/get_current_account and with the headers set according to the https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account info. Authentication token is correct because it works after the below described ‘fix’ below.
The error "OSError: [Errno 116] ETIMEDOUT" is thrown by a socket.recv_into(result) line (from the original adafruit_requests.py implementation code) meant to check the first character/byte of the response from the server (checked to be “H”). Strangely the only way I found to 'solve' this error here was to insert a time.sleep(0.02) before each of the corresponding request data is sent with socket.send()
The observed error is described in more details in the https://github.com/istvanzk/xiaocam_cpy?tab=readme-ov-file#adafruit_requests_fix section, with additional discussions and attempts to debug it on the Adafruit_CircuitPython_Requests issue #209.
The error can be reproduced using the https://github.com/istvanzk/xiaocam_cpy/blob/main/dbx_test.py code when the original adafruit_requests module is used instead of my modified https://github.com/istvanzk/xiaocam_cpy/blob/main/adafruit_requests_fix.py.
Question #0: Is there a particular way the Dropbox API server handles the socket requests/connections? I could not find anything in particular when going through the official Dropbox API Python SDK code, but I might have missed it.
Question #1: After applying the 'fix' described above, the image file upload times are unexpectedly very large e.g., it was approx. 20 seconds for an image of 50KB. Combined with Q#0 it seems the connection is somehow rate limited but I was not able to find the reasons for this.
NOTE: I had to remove all links in this post due to the