Quote
Under the account section there is a create session token operation. You can use that to login using username and password. It will return the JWT.
Yeah, that's what I tried first. This `curl` request works:
Quote
curl "https://api.mangaupdates.com/v1/account/login" -X PUT -H "Content-Type: application/json" -d "{\"username\":\"klaster_1\",\"password\":\"foobar\"}"
But an a rough `fetch` equivalent complains about CORS:
Quote
fetch('https://api.mangaupdates.com/v1/account/login',{method: 'PUT',headers: {'Content-Type': 'application/json'},mode: 'cors',body: JSON.stringify({username: 'klaster_1', password: 'foobar'})})
Quote
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.mangaupdates.com/v1/account/login. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
Rant: the MU commenting system garbles the code.
Quote
You also only have one session, so if you logout on the API or browser it will log you out on the other.
Does "one session" limitation means only a single JWT at a time? If true, what if I want to access API from different applications? Or I should just reuse the same token across the apps? Does the token expire at the same time as the session, what's the TTL?
Quote
What would you need to get your script working? Originally we designed this to be used programmatically by a backend service, not by a browser, so I need to know more about your use case.
You can allow CORS from anywhere by setting the "Access-Control-Allow-Origin" header to "*" (MDN). Just make sure it works with fetch. My use cases:
1. A userscript that checks all items in a list and marks completed or scanlated items as checked. Helps managing wishlists, I have separate lists for ongoing and completed, but not fully scanlated series. At the moment, I just fetch and parse item pages directly, one request per item. With JSON, no parsing would be necessary and less data to transfer.
2. A custom browser extension to indicate amount of series with unread chapters available.
Last edited by Klaster_1 at 7:00 am, May 15 2022