AttributeError: ‘SpeckleException’ object has no attribute ‘referencedObject’

I am facing the issue when I am trying to publish the Speckle app on streamlit.

I am facing issue with
obj_id = commit.referencedObject
error is
AttributeError: ‘SpeckleException’ object has no attribute ‘referencedObject’

I suspect without knowing the message within that SpeckleExcepton that the error thrown by the previous statement will be along the lines of “client is not authenticated” or equivalent.

You will find that running the code locally falls back to using locally stored account credentials that are not present at streamlit runtime.

Suggest you look at

  1. How you are authenticating the client
  2. You have permission to access that Speckle project

There are a few unknowns still, but we’re here to help

This is my github link

The project works well on local but it it sends error when I am trying to run it on streamlit app.

Yes, then what i suggested earlier is what is happening.

You are using the Wrapper to generate a client - this works well locally as it will use accounts on your machine as the authentication reference. When running under the streamlit, there are no such local accounts.

you are actually doing things correctly in the input section:

# client
client = SpeckleClient(host=speckleServer)
# get account from token
account = get_account_from_token(speckleToken, speckleServer)
# authenciaction

but later, where the error occurs:

# wrapper
wrapper = StreamWrapper(commit_url)
# client
client = wrapper.get_client()   ### THIS ASSUMES LOCAL ACCOUNTS WHICH DONT EXIST
# trasnport
transport = wrapper.get_transport()
commit = client.commit.get(wrapper.stream_id, wrapper.commit_id)

This wrapper generated client clientis now an unauthenticated client, and the SpeckleException will be complaining as such with that client commit get

Hence that commit variable is an SpeckleException object, which naturally doesn’t contain a referencedObject property.

So, can you help me with the suggestion for the error?

Is there any documentation to handle this?

Replicate what I said was working correctly in your repo code

in short hand, the most straightforward method would be this:

client = SpeckleClient(host=SERVER_URL) 

We also have community solutions found here: