-
-
Save jetpacktuxedo/67a2fbed24633c3190fe051108e44e37 to your computer and use it in GitHub Desktop.
Sample python script to update the `endpoint` of your `AtprotoLabeler`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
baseurl = "https://bsky.social/xrpc" | |
headers = { | |
"Content-Type": "application/json", | |
"Accept": "application/json" | |
} | |
def auth(handle, pass): | |
payload = { | |
"identifier": handle, | |
"password": password | |
} | |
response = requests.post( | |
f"{baseurl}/com.atproto.server.createSession", | |
headers=headers, | |
json=payload | |
) | |
token = json.loads(response.text).get('accessJwt') | |
headers["Authorization"] = f"Bearer {token}" | |
def requestPlcSig(): | |
response = requests.post( | |
f"{baseurl}/com.atproto.identity.requestPlcOperationSignature", | |
headers=headers, | |
) | |
return response | |
def signPlcOp(url, plcToken): | |
services = { | |
"atproto_labeler": { | |
"type": 'AtprotoLabeler', | |
"endpoint": url | |
}, | |
"atproto_pds": { | |
"type": "AtprotoPersonalDataServer", | |
"endpoint": "bsky pds server" | |
} | |
} | |
payload = { | |
"token": plcToken, | |
"services": services, | |
} | |
response = requests.post( | |
f"{baseurl}/com.atproto.identity.signPlcOperation", | |
headers=headers, | |
json=payload, | |
) | |
operation = json.loads(response.text).get("operation") | |
return operation | |
def submitPlcOp(operation): | |
response = requests.post( | |
f"{baseurl}/com.atproto.identity.submitPlcOperation", | |
headers=headers, | |
json={"operation": operation} | |
) | |
return response | |
auth("your handle here", "and a password too") | |
rquestPlcSig() # This will email you, you'll need that token out of the email for the next step | |
submitPlcOp(signPlcOp("your desired new url", "that token from the email")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment