Replies: 1 comment
-
I'm not familiar with Wallabag, but here's what I'd try given this documentation:
const token = JSON.parse(response.body).access_token;
setVariable("myToken", token); This will extract the token from the response and store it into our variable from earlier. Now if you run the tokenShortcut, it should fetch a token and store it. After that, you should be able to run the myShortcut that you created. It will keep working until the token expires (which seems to be after 1 hour). I'm not sure how the token-refresh is supposed to work either, but you can probably just re-run the token request and get a new token. Not sure what the proper way would be to detect that the token has expired, but it can probably be detected by checking the response status code, which is likely going to be a 403 or 401 in this case. You could try to do the following: if (response && (response.code == 401 || response.code == 403)) {
executeShortcut("tokenShortcut");
enqueueShortcut();
} This will check the HTTP status code for an auth failure, and if it detects one it immediately runs the "tokenShortcut" and then schedules the current shortcut (i.e. myShortcut) to run again afterwards. This is largely just some educated guesses from my side, but I hope it will help you figure out the rest. Some tweaks might be required, in particular to the expiration detection. You can find more details about the Scripting feature of the app here: https://http-shortcuts.rmy.ch/scripting |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make a shortcut that lets me send a URL to Wallabag (a self hosted place to store web pages for reading later, kind of like Pocket). I'm stuck on how to authenticate with the server. It uses quite short lived bearer tokens (if that's the correct name for them, I'm literally learning about this while writing this out...)
They have an API documented here https://app.wallabag.it/api/doc/ but I don't understand how to authenticate.
The instructions lead me through creating a client ID and secret, which I then need to...
The bit I don't understand is how to get the tokens in the first place, and then how to get a new token when the current one expires (and how to work out it has expired). The actual process of using a token and the API I can probably figure out myself.
Beta Was this translation helpful? Give feedback.
All reactions