Skip to content

Instantly share code, notes, and snippets.

@chromabox
Last active February 14, 2024 09:26
Show Gist options
  • Save chromabox/14178330e446544feeb9ff00d974d8d4 to your computer and use it in GitHub Desktop.
Save chromabox/14178330e446544feeb9ff00d974d8d4 to your computer and use it in GitHub Desktop.
blueskyのハンドルネームからdidを問い合わせて取り出すbashスクリプト(認証必要なし&要curl jq)
#!/bin/bash
# bluesky did to handle resolver
# written by chromabox
#
# requirements curl jq
# apt install curl jq
#
user_handle=${1}
api_endpoint="https://bsky.social/xrpc/com.atproto.identity.resolveHandle"
echo "bluesky resolve handle name to did ${user_handle} .... "
jsonout="$(curl -s -G -d handle=$user_handle $api_endpoint)"
raw_did=$(echo "$jsonout" | jq -r '.did')
#echo $raw_did
if [ "$raw_did" == "null" ]; then
echo "error: request missing!!!! did entry isnot found."
echo "responce:"
echo $jsonout
exit 1
fi
echo "${user_handle} did is ${raw_did}"
@chromabox
Copy link
Author

didはdid:plc:も含めないとだめらしい
したがつて…

$ ./bluesky_query_did.sh chromarock.bsky.social
bluesky resolve handle name to did chromarock.bsky.social ....
chromarock.bsky.social did is did:plc:ezccyc3owli52xsxysmifvps

となります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment