File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7878except ImportError :
7979 from urllib import urlencode
8080
81+ BEARER = 'Bearer'
8182##############################################################################
8283# Service
8384##############################################################################
@@ -516,9 +517,13 @@ def recognize_with_websocket(self,
516517 if 'headers' in kwargs :
517518 headers .update (kwargs .get ('headers' ))
518519
519- authstring = "{0}:{1}" .format (self .username , self .password )
520- base64_authorization = base64 .b64encode (authstring .encode ('utf-8' )).decode ('utf-8' )
521- headers ['Authorization' ] = 'Basic {0}' .format (base64_authorization )
520+ if self .token_manager :
521+ access_token = self .token_manager .get_token ()
522+ headers ['Authorization' ] = '{0} {1}' .format (BEARER , access_token )
523+ else :
524+ authstring = "{0}:{1}" .format (self .username , self .password )
525+ base64_authorization = base64 .b64encode (authstring .encode ('utf-8' )).decode ('utf-8' )
526+ headers ['Authorization' ] = 'Basic {0}' .format (base64_authorization )
522527
523528 url = self .url .replace ('https:' , 'wss:' )
524529 params = {
You can’t perform that action at this time.
0 commit comments