Linus2punkt0 / bluesky-crossposter

An app for crossposting your posts from bluesky to twitter and mastodon
108 stars 23 forks source link

Handles on their own domain ? #23

Closed benborges closed 1 year ago

benborges commented 1 year ago

Hey, thanks for this great idea, I'm testing it but can't reach auth, perhaps because of this ? https://github.com/Linus2punkt0/bluesky-crossposter/blob/c73c20c7e6634c445600c9cf863325dc29c270c3/auth.py#L4 What about specifying a PDS so that users using their own domain can also login ?

Traceback (most recent call last): File "/code/bluesky-crossposter/crosspost.py", line 15, in <module> bsky.login(bsky_handle, bsky_password) File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 67, in login session = self._get_and_set_session(login, password) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 37, in _get_and_set_session session = self.com.atproto.server.create_session( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1682, in create_session response = self._client.invoke_procedure( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/base.py", line 82, in invoke_procedure return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 34, in _invoke return super()._invoke(invoke_type, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/base.py", line 89, in _invoke return self.request.post(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 112, in post return _parse_response(self._send_request('POST', *args, **kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 102, in _send_request _handle_request_errors(e) File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 35, in _handle_request_errors raise exception File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 100, in _send_request return _handle_response(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 58, in _handle_response raise exceptions.UnauthorizedError(error_response) atproto.exceptions.UnauthorizedError: Response(success=False, status_code=401, content=XrpcError(error='AuthenticationRequired', message='Invalid identifier or password'), headers=Headers({'date': 'Sun, 17 Sep 2023 18:56:52 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '77', 'connection': 'keep-alive', 'x-powered-by': 'Express', 'access-control-allow-origin': '*', 'ratelimit-limit': '30', 'ratelimit-remaining': '28', 'ratelimit-reset': '1695063412', 'ratelimit-policy': '30;w=300', 'etag': 'W/"4d-98r3hvgolnybv7tgksQiZbSE7Zg"', 'vary': 'Accept-Encoding'}))

Linus2punkt0 commented 1 year ago

Using your own domain should be no issue, I am doing it on my personal account. Currently there is a rate-limit issue which seems to be related to a mistake on bluesky's part when adding new rate limits: https://github.com/bluesky-social/atproto/issues/1616?fbclid=IwAR0l4bG_jJjGQ370S1WAGmsaMh83wy9XmwNhDjnDh0KdLCSvyiZXoa3zJSI

Linus2punkt0 commented 1 year ago

Bluesky have no resolved their issues with rate-limits, so things should work again. If any issues persist, let me know.

benborges commented 1 year ago

I just can't login, ever since first run, I have this error i'm probably doing something wrong but I have no idea what image

Linus2punkt0 commented 1 year ago

Are you getting the same error as the one you sent above? Can you try signing in normally with the username and password given in the auth file?

Also, note that if you have POST_DEFAULT set to true and English set as the twitter_lang, only posts not in English will be crossposted. The lang-toggle is used to exclude posts from the default setting, meaning if the default is true then all posts that don't use the specified language are crossposted, and if it is false only posts that use the specified language are crossposted.

benborges commented 1 year ago

this is what I get when I'm using my original bluesky handle @benborges.xyz and original password, not app password

Traceback (most recent call last):
  File "/run/media/benb/data/code/bluesky-crossposter/crosspost.py", line 15, in <module>
    bsky.login(bsky_handle, bsky_password)
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 67, in login
    session = self._get_and_set_session(login, password)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 37, in _get_and_set_session
    session = self.com.atproto.server.create_session(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 1682, in create_session
    response = self._client.invoke_procedure(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/base.py", line 82, in invoke_procedure
    return self._invoke(InvokeType.PROCEDURE, url=self._build_url(nsid), params=params, data=data, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/client.py", line 34, in _invoke
    return super()._invoke(invoke_type, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/client/base.py", line 89, in _invoke
    return self.request.post(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 112, in post
    return _parse_response(self._send_request('POST', *args, **kwargs))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 102, in _send_request
    _handle_request_errors(e)
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 35, in _handle_request_errors
    raise exception
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 100, in _send_request
    return _handle_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/benb/data/code/bluesky-crossposter/lib/python3.11/site-packages/atproto/xrpc_client/request.py", line 58, in _handle_response
    raise exceptions.UnauthorizedError(error_response)
atproto.exceptions.UnauthorizedError: Response(success=False, status_code=401, content=XrpcError(error='AuthenticationRequired', message='Invalid identifier or password'), headers=Headers({'date': 'Fri, 22 Sep 2023 15:26:14 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '77', 'connection': 'keep-alive', 'x-powered-by': 'Express', 'access-control-allow-origin': '*', 'ratelimit-limit': '30', 'ratelimit-remaining': '29', 'ratelimit-reset': '1695396674', 'ratelimit-policy': '30;w=300', 'etag': 'W/"4d-98r3hvgolnybv7tgksQiZbSE7Zg"', 'vary': 'Accept-Encoding'}))
Linus2punkt0 commented 1 year ago

It’s still giving an authentication error. Could you send me a screenshot of the auth file with the password blurred?

benborges commented 1 year ago

I tested with an alt account with handle.bsky.social + original password = same error

Tried with an app password, same error.

so it's probably my .env file

image

Linus2punkt0 commented 1 year ago

Are you using docker compose or docker run when attempting to start it? Because docker run will not read the env file. Also, run interval is set in seconds, so 12 gonna be a bit too fast. And finally you have false with a minor case f for mastodon posting. It needs to be upper case.

benborges commented 1 year ago

For now I'm just testing without using the docker part, so running with python locally

Linus2punkt0 commented 1 year ago

If you are not using docker you need to enter the auth information in auth.py and not in the env-file.

benborges commented 1 year ago

Oh damn, then this issue can be closed.

it works right away when using auth.py, I was using python with .env

and it obviously works with handles on their own domain !

thanks for this code, you just woke up my twitter account from the dead :)