Skip to content

Instantly share code, notes, and snippets.

@camlspotter
Created July 4, 2023 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camlspotter/636940c828e39bc258eef420b6eba904 to your computer and use it in GitHub Desktop.
Save camlspotter/636940c828e39bc258eef420b6eba904 to your computer and use it in GitHub Desktop.
Access BlueSky
# You need
#
# - curl
# - jq
# Your handle, ex xxxx.bsky.social or your custom handle like dailambda.jp.
# No '@' mark.
HANDLE=hogehoge.bsky.social
# Your App password: Settings > App password > Add App password
APP_PASSWORD=hoge-hoge-hoge-hoge
# Your identity. No auth required.
curl https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=$HANDLE | jq
# Get the session key
if [ ! -f _auth ]; then
curl --json '{ "identifier" : "'$HANDLE'", "password": "'$APP_PASSWORD'" }' \
https://bsky.social/xrpc/com.atproto.server.createSession > _auth
fi
accessJwt=$(jq -r .accessJwt < _auth)
echo "Authorized"
# Get your last 10 posts
curl --header "Content-Type: application/json" \
--header "Authorization: Bearer $accessJwt" \
"https://bsky.social/xrpc/app.bsky.feed.getAuthorFeed?actor=$HANDLE&limit=10" | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment