Accessing stream via google colab

  • 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("")

client = wrapper.get_client()

transport = wrapper.get_transport()" 
1 Like

Merhaba Murat,

Welcome to the community! Feel free to Introduce yourself :person_gesturing_ok: to the community if you want to! :grinning:

Can you please share the permission/scope of your token?

Hello Murat,

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("")
client = SpeckleClient()
account = get_account_from_token(SPECKLE_TOKEN, wrapper.server_url)

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:

It should list all the projects associated with your account.

1 Like

Thank you @gokermu . Your script worked.

1 Like