Most certainly. I’ll look up how in a minute because you got me curious, but I’m sure you can.
how would you attach the authentification token? is there a builtin way to do such a thing or would it require abusing the command in some way?
No abusing necessary – authentification is such a basic part of applications that it would be quite silly not to have a standard way to do so.
Auth tokens are usually in the Header, a bit of information preceding the actual body of the request (if the request has a body; not all do). Basically, if your comment is a package with the address of the server written on it, the server opens the package and the first thing it sees is a sheet of extra information.
Part of it is information about how to unpack and read the rest, instructions on how to repackage the result, various technical bits I won’t get into, but the part we care about is the Authorization. It usually comes in the form of some weird string of letters and digits, preceded by an identifier for the type of token. How that token is negotiated is a different question, but in any case, it’s something that both server and client have agreed upon and nobody else should know.
With curl, specifically, you attach Headers with the -H flag. An example using a Bearer token stored in a variable ACCESS_TOKEN might look like this:
curl -H "Authorization: Bearer $ACCESS_TOKEN" URI
So on the question of sending your comment with curl:
You’d probably use a POST request (-X POST) to send a new comment, a content type description header (-H "Content-Type: application/json") and a request body for the comment data (-d 'request body'), and obviously the URI for your lemmy server’s “post a new comment” endpoint (basically an inbox for a specific task).
I’ll see if I can find out the details of how to authenticate and how to package the body, if you want to try.
Ask away! I’m delighted to answer.
Most certainly. I’ll look up how in a minute because you got me curious, but I’m sure you can.
No abusing necessary – authentification is such a basic part of applications that it would be quite silly not to have a standard way to do so.
Auth tokens are usually in the Header, a bit of information preceding the actual body of the request (if the request has a body; not all do). Basically, if your comment is a package with the address of the server written on it, the server opens the package and the first thing it sees is a sheet of extra information.
Part of it is information about how to unpack and read the rest, instructions on how to repackage the result, various technical bits I won’t get into, but the part we care about is the Authorization. It usually comes in the form of some weird string of letters and digits, preceded by an identifier for the type of token. How that token is negotiated is a different question, but in any case, it’s something that both server and client have agreed upon and nobody else should know.
With curl, specifically, you attach Headers with the -H flag. An example using a Bearer token stored in a variable ACCESS_TOKEN might look like this:
curl -H "Authorization: Bearer $ACCESS_TOKEN" URISo on the question of sending your comment with curl:
You’d probably use a POST request (
-X POST) to send a new comment, a content type description header (-H "Content-Type: application/json") and a request body for the comment data (-d 'request body'), and obviously the URI for your lemmy server’s “post a new comment” endpoint (basically an inbox for a specific task).I’ll see if I can find out the details of how to authenticate and how to package the body, if you want to try.
I sure do ;-)