@@ -131,6 +131,18 @@ def authenticate_with_token(self, token: str) -> None:
131131 self .account = Account .from_token (token , self .url )
132132 self ._set_up_client ()
133133
134+ userData = self .active_user .get ()
135+
136+ # None if the token lacked the profile:read scope or if it was None
137+ if userData :
138+ self .account .userInfo .id = userData .id
139+ self .account .userInfo .email = userData .email
140+ self .account .userInfo .name = userData .name
141+ self .account .userInfo .company = userData .company
142+ self .account .userInfo .avatar = userData .avatar
143+
144+ self .account .serverInfo = self .server .get ()
145+
134146 def authenticate_with_account (self , account : Account ) -> None :
135147 """Authenticate the client using an Account object
136148 The account is saved in the client object and a synchronous GraphQL
@@ -143,6 +155,21 @@ def authenticate_with_account(self, account: Account) -> None:
143155 self .account = account
144156 self ._set_up_client ()
145157
158+ try :
159+ _ = self .active_user .get ()
160+ except SpeckleException as ex :
161+ if isinstance (ex .exception , TransportServerError ):
162+ if ex .exception .code == 403 :
163+ warn (
164+ SpeckleWarning (
165+ "Possibly invalid token - could not authenticate "
166+ f"Speckle Client for server { self .url } "
167+ ),
168+ stacklevel = 2 ,
169+ )
170+ else :
171+ raise ex
172+
146173 def _set_up_client (self ) -> None :
147174 headers = {
148175 "Authorization" : f"Bearer { self .account .token } " ,
@@ -162,21 +189,6 @@ def _set_up_client(self) -> None:
162189
163190 self ._init_resources ()
164191
165- try :
166- _ = self .active_user .get ()
167- except SpeckleException as ex :
168- if isinstance (ex .exception , TransportServerError ):
169- if ex .exception .code == 403 :
170- warn (
171- SpeckleWarning (
172- "Possibly invalid token - could not authenticate "
173- f"Speckle Client for server { self .url } "
174- ),
175- stacklevel = 2 ,
176- )
177- else :
178- raise ex
179-
180192 def execute_query (self , query : str ) -> Dict :
181193 return self .httpclient .execute (query )
182194
0 commit comments