Could someone shed light on this? @paul121?
I have some problems sending data to a stream, and also authenticating with FarmOS.
The CURL example in the develpoer info is working. But my python-sctipts get <Response [500]> error.
My first thought is a bug in the script, but I can’t find any.
I also tried some other simple import scripts that used to work before. But now I just get the errors below. These errors are present in all scripts authenticating to Farmos. Including the https://gist.github.com/paul121/7ec9685b6ca216b3b0173d8a16f1de04 planting.csv import example.
**Traceback (most recent call last):**
File “/home/jk/PycharmProjects/Farmos/CSV_Plant_import.py”, line 37, in
client.authorize(username, password)
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/farmOS/ **init** .py”, line 142, in authorize
return self.session.authorize(username, password, scope)
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/farmOS/session.py”, line 70, in authorize
token = self.fetch_token(
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py”, line 366, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py”, line 448, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 441, in parse_token_response
validate_token_parameters(params)
File “/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 451, in validate_token_parameters
raise MissingTokenError(description=“Missing access token parameter.”)
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
Process finished with exit code 1
Hey @pat seems like this is related to OAuth. Were you able to authenticate with your server previously? And if so, has anything changed?
That planting.csv example should still work, but you could also try the farmOS.py Quick Start: Introduction | farmOS
Note that sending data to a data stream does not require OAuth, but does require that you include the private_key parameter. This also isn’t a “supported” feature of farmOS.py - meaning there are no “helper” methods for sending data to data streams. But you should be able to use the underlying requests session to make these custom requests eg: client.session.post(url, data, ..)
Well, long story…
Started with free v1 hosting at first. Jumped on v2 hosting after beta release. Now I’m on the first alternative with subscription and migrated to v2. (Due to the support of csv import in v1)
There was some hickups and bugs with this all the way, but I did mange to import stuff from python scripts. But to be honest, I don’t remember what worked where and when. (No scripts for v1 tho)
Left all this behind, and waited for the migration.
One change is reinstallation of my computer, and a new setup of PyCharm.
And get the following error.
Yep, I did change the hostname
Login details are cut&paste from my password mananger, and works for logging in to my hosted instance.
Traceback (most recent call last):
File "/home/jk/PycharmProjects/Farmos/auth.py", line 9, in <module>
token = farm_client.authorize()
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/farmOS/__init__.py", line 142, in authorize
return self.session.authorize(username, password, scope)
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/farmOS/session.py", line 70, in authorize
token = self.fetch_token(
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 366, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 448, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response
validate_token_parameters(params)
File "/home/jk/PycharmProjects/Farmos/venv/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 451, in validate_token_parameters
raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
Process finished with exit code 1
@paul121 Uh… I might add that while running FarmOS v1 I somtimes had problems logging in the fieldkit web app. Didn’t pay any attention to it since I wasn’t to stay at v1.