this post was submitted on 14 Jun 2023
30 points (100.0% liked)
Programming
13382 readers
1 users here now
All things programming and coding related. Subcommunity of Technology.
This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Okay, before I head off to bed, I think this works for the login and authentication token:
The JSON Web Token (jwt) should contain the authentication token. At least I think that's the case. I picked this out by reading through the Go code at the following URL: https://github.com/Elara6331/go-lemmy/blob/master/lemmy.go
I'll play around with the code later.
Sorry for the late response to my other comment - I also was reading through the documentation for the first time and it looks like you got the answer ahead of me, nice!
I whipped up some sample code that does exactly the same thing you ended up doing, so no further additions here except that in the Lemmy API is expecting requests to be sent to
<instance domain>/api/v3/...
.I used my code that is basically the same to what you have above here, but when I switched it to v1 the server throws an 400 error (malformed request). So if you haven't ran this code already you've got my sanity check that it will work except for making sure you change the api version. You can then carry that auth token with you when making requests by including it in the header like so
Thanks, I'll revamp my code when I start testing it later. I think eventually I'll put together a python library for interacting with Lemmy, or at least give enough of an example that someone else can get a good start.