Specklepy AttributeError: 'str' object has no attribute 'me'

I’m trying to get the following code to work (from the specklepy documentation)

from specklepy.api import operations
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_default_account
from specklepy.transports.server import ServerTransport

HOST = “https://speckle.xyz
STREAM_ID = “2413489097”
COMMIT_ID = “5110ae0a56”

create and authenticate a client

client = SpeckleClient(host=HOST)
account = get_default_account()
client.authenticate(token=account.token)

get the specified commit data

commit = client.commit.get(STREAM_ID, COMMIT_ID)

create an authenticated server transport from the client and receive the commit obj

print(client.me) # this line prints "{‘token’: actual token value}
transport = ServerTransport(client, STREAM_ID) # this line throws the error
res = operations.receive(commit.referencedObject, transport)

get the list of levels from the received object

levels = res[“data”]

however, I’m getting to following error,
Traceback (most recent call last):
File “C:\Users\civy\GitHub\demo-specklepy\demo_specklepy\test.py”, line 23, in
transport = ServerTransport(client, STREAM_ID)
File “C:\Users\civy\GitHub\demo-specklepy.venv\lib\site-packages\specklepy\transports\server\server.py”, line 68, in init
if not client.me:
AttributeError: ‘str’ object has no attribute ‘me’

This error has been seen before (Blender error: AttributeError: 'str' object has no attribute 'me') but I can’t find anything about resolving the error in specklepy.

I’m using specklepy 2.5.2 and python 3.9 (I’ve also tried with python 3.7)

Thanks for your help.

Hi,

Oh, I see that the arguments are in the reversed order for ServerTransport.
It should be one of:

  • ServerTransport(STREAM_ID, client)
  • ServerTransport(client=client, stream_id=STREAM_ID)

instead of ServerTransport(client, STREAM_ID).

Can you provide a link to the documentation so we can update it?
Thanks

3 Likes

Thanks for the quick reply! That was it. I was trying to follow the ‘simple dashboard’ tutorial found here Tutorial: Simple Dashboard | Speckle Docs