Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Basic login script for Lemmy API
- # CHANGE THESE VALUES
- my_instance="https://feddit.de" # e.g. https://feddit.nl
- my_username="" # e.g. freamon
- my_password="" # e.g. hunter2
- ########################################################
- # Lemmy API version
- API="api/v3"
- ########################################################
- # Turn off history substitution (avoid errors with ! usage)
- set +H
- ########################################################
- # Login
- login() {
- end_point="user/login"
- json_data="{\"username_or_email\":\"$my_username\",\"password\":\"$my_password\"}"
- url="$my_instance/$API/$end_point"
- curl -H "Content-Type: application/json" -d "$json_data" "$url"
- }
- # Get userdata as JSON
- getUserData() {
- end_point="user/export_settings"
- url="$my_instance/$API/$end_point"
- curl -H "Authorization: Bearer ${JWT}" "$url"
- }
- JWT=$(login | jq -r '.jwt')
- printf 'JWT Token: %s\n' "$JWT"
- getUserData | jq > myFedditUserData.json
Advertisement
Add Comment
Please, Sign In to add comment