Specklepy Authentication & SSL Certificate

Hello I am having difficulty when starting out with Specklepy and following the example and tutorials in the documentation.

When I try and use either StreamWrapper or SpeckleClient to talk to my server it is throwing the following error.

Traceback (most recent call last):
  File "C:\Users\UKBWS001\dev\specklepy\app.py", line 5, in <module>
    client = wrapper.get_client()
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\api\wrapper.py", line 72, in get_client
    return super().get_client(token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\core\api\wrapper.py", line 220, in get_client
    self._client.authenticate_with_account(self._account)
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\core\api\client.py", line 157, in authenticate_with_account
    self._set_up_client()
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\core\api\client.py", line 184, in _set_up_client
    raise user_or_error
specklepy.logging.exceptions.SpeckleException: SpeckleException: Failed to execute the GraphQL active_user request. Inner exception: HTTPSConnectionPool(host='app.speckle.systems', port=443): Max retries exceeded with 
url: /graphql (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')))

I am using these links for my Host:
https://app.speckle.systems/ + Access Token

or

https://app.speckle.systems/projects/14ab4b0266
when using the StreamWrapper

1 Like

Hey @Ben-Sayers_wsp,

Welcome to the community! :cool_spockle:

Funnily enough, we were just speaking about this method of authentication yesterday. Some questions off the bat:

  • I believe the Host url will be just the https://app.speckle.systems/ without the access token
  • Assuming the access token has also been created in the app.speckle.systems (with adequate permissions)? Do you by chance also have an account under latest.speckle.systems that is linked to manager? Or multiple accounts linked to manager? For example, I have two below:

  • Could you try a different route of authentication for me:
# Global variables
SPECKLE_TOKEN="ADD_YOUR_TOKEN_HERE"
SPECKLE_SERVER_URL="https://app.speckle.systems/"
SPECKLE_PROJECT_ID="14ab4b0266" # Grabbed from your link, thanks!

# Authentications
client = SpeckleClient(host=SPECKLE_SERVER_URL)
client.authenticate_with_token(SPECKLE_TOKEN) # Confirm if this works please

# Taking it one step further
transport = ServerTransport(client=client, stream_id=SPECKLE_PROJECT_ID)
project = client.stream.get(id=SPECKLE_PROJECT_ID)
main_model = client.branch.get(SPECKLE_PROJECT_ID, 'main')

Cheers,
Björn

Hi bjoer,

Thank you for your quick response!

I have tried your snippet and having the same issues.

This is my current python file with my access token replaced for the generated one on my developer profile.

from specklepy.api.client import SpeckleClient
from specklepy.transports.server import ServerTransport

# Global variables
SPECKLE_TOKEN="MY-ACCESS-TOKEN"
SPECKLE_SERVER_URL="https://app.speckle.systems/"
SPECKLE_PROJECT_ID="14ab4b0266" # Grabbed from your link, thanks!

# Authentications
client = SpeckleClient(host=SPECKLE_SERVER_URL)
client.authenticate_with_token(SPECKLE_TOKEN) # Confirm if this works please

# Taking it one step further
transport = ServerTransport(client=client, stream_id=SPECKLE_PROJECT_ID)
project = client.stream.get(id=SPECKLE_PROJECT_ID)
main_model = client.branch.get(SPECKLE_PROJECT_ID, 'main')

This is my Speckle Manager

My Access token permissions are:
workspace: create / read / delete / update

This is the recent error log:

(venv) PS C:\Users\UKBWS001\dev\specklepy> python app.py
Traceback (most recent call last):
  File "C:\Users\UKBWS001\dev\specklepy\app.py", line 11, in <module>
    client.authenticate_with_token(SPECKLE_TOKEN) # Confirm if this works please
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\api\client.py", line 146, in authenticate_with_token
    return super().authenticate_with_token(token)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\core\api\client.py", line 145, in authenticate_with_token
    self._set_up_client()
  File "C:\Users\UKBWS001\dev\specklepy\venv\Lib\site-packages\specklepy\core\api\client.py", line 184, in _set_up_client
    raise user_or_error
specklepy.logging.exceptions.SpeckleException: SpeckleException: Failed to execute the GraphQL active_user request. Inner exception: HTTPSConnectionPool(host='app.speckle.systems', port=443): Max retries exceeded with url: /graphql (Caused by SSLError(SSLCertVer
url: /graphql (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)')))
(venv) PS C:\Users\UKBWS001\dev\specklepy>

Specklepy is installed in my active virtual environment

1 Like

Aha, thanks for the extra info @Ben-Sayers_wsp. Can you try creating a new token and extend the scope to also add streams:read, streams:write, profile:read.

Kindly also have a look here QGIS: SSLError, A failure in the SSL library occured - #20 by JoostGevaert

1 Like