MCPcopy
hub / github.com/spaceandtimefdn/SxT-Python-SDK / authenticate

Method authenticate

src/spaceandtime/spaceandtime.py:89–119  ·  view source on GitHub ↗

-------------------- Authenticate user to Space and Time. Uses the default dotenv file to create a default user, if no other is supplied. Args: user (SXTUser): (optional) SXTUser object used to authenticate, and set as default user. Creates new from default dot

(self, user:SXTUser = None)

Source from the content-addressed store, hash-verified

87
88
89 def authenticate(self, user:SXTUser = None):
90 """--------------------
91 Authenticate user to Space and Time. Uses the default dotenv file to create a default user, if no other is supplied.
92
93 Args:
94 user (SXTUser): (optional) SXTUser object used to authenticate, and set as default user. Creates new from default dotenv file if omitted.
95
96 Returns:
97 bool: Success indicator
98 str: Access Token returned from Space and Time network
99
100 Examples:
101 >>> sxt = spaceandtime()
102 >>> success, access_token = sxt.authenticate()
103 >>> print( success )
104 True
105 >>> print( len(access_token) >= 64 )
106 True
107
108 """
109 if not user: user = self.user
110 if self.network_calls_enabled:
111 success, rtn = user.authenticate()
112 else:
113 user.access_token = 'eyJ0eXBlI_this_is_a_pretend_access_token_it_will_not_really_work_4lXUgI5gIdk8T5Rb4Zlx8-Z1rlY-0y4pu5b4lIjh60wQY_g0vkteuQE0Or0cPDbstDnLg8uRpz5dM4GNg7QHYQ'
114 user.refresh_token = 'eyJ0eXBlI_this_is_a_pretend_refresh_token_it_will_not_really_work_4lXUgI5gIdk8T5Rb4Zlx8-Z1rlY-0y4pu5b4lIjh60wQY_g0vkteuQE0Or0cPDbstDnLg8uRpz5dM4GNg7QHYQ'
115 success, rtn = (True, user.access_token)
116 user.base_api.access_token = self.user.access_token
117 self.logger.info(f'Authentication Success: {success}')
118 if not success: self.logger.error(f'Authentication error: {str(rtn)}')
119 return success, rtn
120
121
122 def execute_query(self, sql_text:str, sql_type:SXTSqlType = SXTSqlType.DQL,

Callers 11

mainFunction · 0.95
__init__Method · 0.95
test_table_discoveryFunction · 0.95
test_apikey_loginFunction · 0.95
test_sxt_exceptionsFunction · 0.95
test_sxt_wrapperFunction · 0.95
test_execute_queryFunction · 0.95
test_discoveryFunction · 0.95

Calls

no outgoing calls

Tested by 9

test_table_discoveryFunction · 0.76
test_apikey_loginFunction · 0.76
test_sxt_exceptionsFunction · 0.76
test_sxt_wrapperFunction · 0.76
test_execute_queryFunction · 0.76
test_discoveryFunction · 0.76