I get this error when trying to run python script CVS upload
raceback (most recent call last):
File “C:\py\import_plantings.py”, line 35, in
client.authorize(username, password)
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\site-packages\farmOS_init_.py”, line 156, in authorize
return self.session.authorize(username, password, scope)
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\site-packages\farmOS\session.py”, line 76, in authorize
token = self.fetch_token(
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\site-packages\requests_oauthlib\oauth2_session.py”, line 366, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\site-packages\oauthlib\oauth2\rfc6749\clients\base.py”, line 427, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\site-packages\oauthlib\oauth2\rfc6749\parameters.py”, line 441, in parse_token_response
validate_token_parameters(params)
File “C:\Users\pieters\AppData\Local\Programs\Python\Python310\lib\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.
and running late version on farmOs.py
PS C:\py> pip show farmOS
Name: farmOS
Version: 1.0.0b3
Summary: A Python library for interacting with farmOS over API.
Home-page: GitHub - farmOS/farmOS.py: A Python library for interacting with farmOS over API.
Author: farmOS team
Author-email: mike@mstenta.net
License: UNKNOWN
Location: c:\users\pieters\appdata\local\programs\python\python310\lib\site-packages
Requires: pydantic, requests-oauthlib
Required-by:
Run on win 10
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32
Hey @silverlynxconsulting farmOS.py version looks good and I see this was triggered by client.authorize(username, password). If you had incorrect credentials I would expect the server to respond accordingly.
The error message you are seeing should never really happen. This error message suggests that the server did not return an access_token parameter. It’s possible there are log messages related to this as well; if you are self-hosting you can view these at /admin/reports/dblog. Can you share what version of farmOS server you are running?
Other than that, you will want to make sure you OAuth client is configured correctly in both the server and python code (default is client_id = 'farm' and no client_secret).
Maybe one thing to check is that your keys are correctly configured. Maybe related, although it looks like this would return a different error message: OAuth keys missing in Docker setup
@paul121 correct me if I’m wrong but that’s a requirement for OAuth2, right? I forget…
@silverlynxconsulting Are you getting any errors from the Python script itself? It looks like most of the logs posted above are from the web server, which probably won’t help in this case.
Don’t believe it is, OAuth2 works with some dev instances I’ve tested without SSL, I’ve had some issues with certain http clients and self-signed Certs that required an additional parameter to ignore untrusted certs, but they always returned an explicit error about the self signed cert.
Are you sure there is no secret set though? I believe the secret box is blank even after saving one.
But there is a Boolean switch to enable/disable the secret.
SSL is loaded it is an intranet server
the client does have an IIS windows web server, and I had to install pip-system-certs 3.1 to help python to use the windows uses Windows certificate store to check the validity of certificates.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
Create the content on the Web server.
Review the browser URL.
Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module
IIS Web Core
Notification
MapRequestHandler
Handler
StaticFile
Error Code
0x80070002
Requested URL
http://geosrv4:80/oauth/token
Physical Path
C:\inetpub\wwwroot\oauth\token
Logon Method
Anonymous
Logon User
Anonymous
More Information:
This error means that the file or directory does not exist on the server. Create the file or directory and try the request again.