rzr / mastodon-lite

Lightweight client for mastodon micro blogging service.
https://purl.org/rzr/mastodon-lite
Apache License 2.0
19 stars 6 forks source link

Support pleroma and document how #13

Open rzr opened 4 years ago

rzr commented 4 years ago

https://pleroma.social/

rzr commented 3 years ago

I think pleromaFE miss the feature to generate apps from web ui

For the record random notes:


## Notes:
website='https://pleroma.fr'
client_name="PleromaFE_deadbeef _2020-09-16T17:20:03.475Z"

host=mastodon.social
#host=pleroma.fr
base_url=https://$host

scopes="read write follow push"
scopes="read"

# base_url=https://mastodon.social
curl -X POST -F "client_name=${client_name}" -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' -F "scopes=${scopes}" -F "website=${website}" "${base_url}/api/v1/apps" | jq . | tee apps.log.tmp

#| {
#|   "client_id": "X-EpoaVeqTir6aZpX4vrKFb0_D1Wa_pz9J8Kdqee9JI",
#|   "client_secret": "6mIaWfJRe0LMEV--dwT8gUuzIfNqsbE1hsrVmWvBnP0",
#|   "id": "48477",
#|   "name": "Test Application",
#|   "redirect_uri": "urn:ietf:wg:oauth:2.0:oob",
#|   "website": "https://myapp.example",
#|   "vapid_key": "BPUTBNRKx9ygHQx4BLz8FvJDYnRNQjF-STIhBCufONjuhgwIlDjDFfVLlR5-_SSq6yGK4UDujd-_g9ROwcd5VPM"
#| }

client_id=$(jq .client_id < apps.log.tmp)

client_secret=$(jq .client_secret < apps.log.tmp)

vapid_key=$(jq .vapid_key < apps.log.tmp)

curl -X POST \
    -F "client_id=${client_id}" \
    -F "client_secret=${client_secret}" \
    -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
    -F 'grant_type=client_credentials' \
        ${base_url}/oauth/token | jq . | tee token.log.tmp

#| {
#|   "access_token": "frBfjnQyu1mrzhtcpfefz1n8RHGMwhjEznf44u7Yj_w",
#|   "created_at": 1600276104,
#|   "expires_in": 600,
#|   "refresh_token": "Afb0yyEnmUX0emTSntHBHQqogHQP-eA23EXRSBVhIVM",
#|   "scope": "read write follow push",
#|   "token_type": "Bearer"
#| }

access_token=$(jq .access_token < token.log.tmp)

cat<<EOF> ~/.mastodon-lite.json
{
  "access_token": ${access_token},
  "host": "${host}",
  "port": 443,
  "api": "/api/v1",
  "rejectUnauthorized": false
}
EOF

 cat ~/.mastodon-lite.json

make start runtime=node
# {"error":"Invalid credentials."}
## Notes:
# https://git.pleroma.social/pleroma/harbour-kyclos/-/blob/develop/qml/pages/LoginPage.qml#L127
website='https://pleroma.fr'
client_name="PleromaFE_deadbeef _2020-09-16T17:20:03.475Z"

host=mastodon.social
#host=pleroma.fr
base_url=https://$host

scopes="read write follow push"
scopes="read"

# base_url=https://mastodon.social
curl -X POST -F "client_name=${client_name}" -F 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' -F "scopes=${scopes}" -F "website=${website}" "${base_url}/api/v1/apps" | jq . | tee apps.log.tmp

#| {
#|   "client_id": "X-EpoaVeqTir6aZpX4vrKFb0_D1Wa_pz9J8Kdqee9JI",
#|   "client_secret": "6mIaWfJRe0LMEV--dwT8gUuzIfNqsbE1hsrVmWvBnP0",
#|   "id": "48477",
#|   "name": "Test Application",
#|   "redirect_uri": "urn:ietf:wg:oauth:2.0:oob",
#|   "website": "https://myapp.example",
#|   "vapid_key": "BPUTBNRKx9ygHQx4BLz8FvJDYnRNQjF-STIhBCufONjuhgwIlDjDFfVLlR5-_SSq6yGK4UDujd-_g9ROwcd5VPM"
#| }

client_id=$(jq .client_id < apps.log.tmp)

client_secret=$(jq .client_secret < apps.log.tmp)

vapid_key=$(jq .vapid_key < apps.log.tmp)

curl -X POST \
    -F "client_id=${client_id}" \
    -F "client_secret=${client_secret}" \
    -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
    -F 'grant_type=client_credentials' \
        ${base_url}/oauth/token | jq . | tee token.log.tmp

#| {
#|   "access_token": "frBfjnQyu1mrzhtcpfefz1n8RHGMwhjEznf44u7Yj_w",
#|   "created_at": 1600276104,
#|   "expires_in": 600,
#|   "refresh_token": "Afb0yyEnmUX0emTSntHBHQqogHQP-eA23EXRSBVhIVM",
#|   "scope": "read write follow push",
#|   "token_type": "Bearer"
#| }

access_token=$(jq .access_token < token.log.tmp)

cat<<EOF> ~/.mastodon-lite.json
{
  "access_token": ${access_token},
  "host": "${host}",
  "port": 443,
  "api": "/api/v1",
  "rejectUnauthorized": false
}
EOF

 cat ~/.mastodon-lite.json

make start runtime=node
# {"error":"Invalid credentials."}