| 13:02 | * | ghpstudent[m] has joined |
| 13:08 | ghpstudent[m] | Hello all, im a (very) new user to FarmOS and i'm interested in using its API feature. My problem however, is that for some reason, i can't seem to make the API work... Whenever i try and call it using postman (eg. the "/farm.json" that is being used as an example on FarmOS api page) i get a status code "403 Forbidden". Again, im not sure what i'm doing wrong... I havent set up any authentication/authorization but, |
| 13:08 | ghpstudent[m] | unless i've missed it, it doesnt seem like a requirement. Anyone know how to make the API work? |
| 13:08 | mstenta[m] | Hi ghpstudent |
| 13:09 | mstenta[m] | Everything in farmOS requires a user login to access |
| 13:09 | mstenta[m] | So you do need to authenticate |
| 13:09 | mstenta[m] | There are various ways to do that, described here: farmos.org/development/api/#authenticati |
| 13:09 | mstenta[m] | Hope that helps! |
| 13:16 | * | sent a long message: < matrix.org/_matrix/media/r0/download/mat > |
| 13:55 | mstenta[m] | Oh yea I think I remember that... |
| 13:56 | mstenta[m] | I think it just means that, by default, you need a user with a name that begins with "restws" eg: "restws-myusername" |
| 13:56 | mstenta[m] | To change that, you need to add a line to your `settings.php` file that overrides a variable |
| 13:56 | mstenta[m] | I think there's an example in the restws readme file? |
| 13:57 | mstenta[m] | git.drupalcode.org/project/restws/blob/H |
| 13:57 | * | sent a long message: < matrix.org/_matrix/media/r0/download/mat > |
| 13:57 | mstenta[m] | So, to allow ANY user, I think you would add: |
| 13:58 | mstenta[m] | $conf['restws_basic_auth_user_regex'] = '/^.*/'; |
| 13:58 | mstenta[m] | * `$conf['restws_basic_auth_user_regex'] = '/^.*/';` |
| 13:58 | mstenta[m] | But I have never done that, so you may need to play around with it |
| 14:32 | ghpstudent[m] | Thanks again for the reply! :) I'll play around with it a little and share my results |
| 14:34 | mstenta[m] | Sure thing! Good luck |
| 16:10 | symbioquine[m] | Perhaps it is worth reiterating that the regex above only applies to HTTP basic auth - i.e. auth where the username/password are passed in the `Authorization` header (populated by the curl -u option). It's only slightly more complicated to use the "Session Cookie and CSRF Token" strategy described by farmos.org/development/api/ which should work with any username out-of-the-box. |
| 16:28 | mstenta[m] | Yes and now we also have an oauth option! :-) |
| 16:47 | * | friedrich[m]1 has joined |