Objective: Retrieve elements from a stream using google colab and StreamWrapper.
Issue: I am getting an error: GraphQLException: GraphQLException: Failed to execute the GraphQL active_user request. Errors: [{‘message’: ‘You do not have the required privileges.’, ‘locations’: [{‘line’: 2, ‘column’: 3}], ‘path’: [‘activeUser’], ‘extensions’: {‘code’: ‘FORBIDDEN’}}]
Example: Here is the short code. Speckle token is stored as a google colab secret.
from specklepy.api.wrapper import StreamWrapper
from specklepy.api.credentials import get_account_from_token
from google.colab import userdata
speckle_token = userdata.get('speckle_token')
wrapper = StreamWrapper("https://speckle.xyz/streams/223c5a7512/commits/19e2907287")
client = wrapper.get_client()
client.authenticate_with_token(token=speckle_token)
transport = wrapper.get_transport()"
I noticed that you have used the wrapper.get_client() method in your code. Just to let you know, the StreamWrapper provides some useful tools to manage URLs and obtain authenticated clients and transports using your local account. Since you are working in Google Colab, I suggest that you modify your code as follows:
from specklepy.api.wrapper import StreamWrapper
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_account_from_token
wrapper = StreamWrapper("https://speckle.xyz/streams/b573f65f0b")
client = SpeckleClient()
account = get_account_from_token(SPECKLE_TOKEN, wrapper.server_url)
client.authenticate_with_account(account)
I’m still using the wrapper class to get the server address from the given URL. After modifying your code, what happens when you run the following:
client.stream.list()
It should list all the projects associated with your account.