I would say that I second this request… but it was actually me that asked David…
Would a quick fix be possible? For example, that there would be an option to feed an API token to client.login instead of a username and password?
Or some other way? David identified that SpeckleBlender updates the https headers to add the token as the Authorization header. Is there a way that I could use this technique (i.e. could someone help me work out how to do this in the short term)?
We have some analysis models that are defined in text files, and I was wondering if I could use Python to parse them and then send Speckle formatted information up to the server (I already have some parsers for reading the files). I am a complete newbie and am trying to get a handle on what would be involved. Anything that could help me (and other newbies) with that would be appreciated.
As per the posting below by David, having easy access to authentication flows would certainly be helpful.
To answer the 1.0 question, there isn’t a way to use client.login directly with the token as the /login route requires the user’s email and password.
However, I can give a cheeky suggestion! The pyspeckle client stores the response of the login request in client.me. You could chuck the token in there directly and use the client that way. I haven’t looked into this very hard so I’m not immediately sure if this will break anything - tread carefully!
However, it seems that my api token does not work in this location. When I compare it to the token that is pulled in by the login function I find that it is much longer than my api token. Am I doing something wrong? Am I doing what you suggested?
I tried what you suggested, and I get the same error as with my approach:
ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //hestia.speckle.works/api/v1/streams/taNRrjz3u (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000014F8CC2D2E8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
Ah regarding your extension of the client, I am afk at the moment so I can’t double check right now but I think you need to populate the me dict (not just the headers) bc the client methods use me['token'] in a few places
@andrew.mole ah just looked at your error message and I think there might be something else going on here. If you weren’t authenticated properly, you would be getting a 401 unauthorised error.
Going to the stream myself, it looks like it doesn’t exist?
If it was an authorisation problem, you would be getting an error message like this: