@@ -66,12 +66,14 @@ def _get_idt_access_token(self) -> str:
6666 logging .info ('Connecting to IDT API' )
6767 data = {'grant_type' : 'password' , 'username' : self .username , 'password' : self .password , 'scope' : 'test' }
6868 auth = HTTPBasicAuth (self .client_id , self .client_secret )
69- result = post (IDTAccountAccessor ._TOKEN_URL , data , auth = auth , timeout = IDTAccountAccessor .SCORE_TIMEOUT )
7069
71- if 'access_token' in result .json ():
72- return result .json ()['access_token' ]
73- else :
74- raise ValueError ('Access token for IDT API could not be generated. Check your credentials.' )
70+ for domain in IDTAccountAccessor ._SUBDOMAINS :
71+ result = post (f'{ domain } { IDTAccountAccessor ._TOKEN_ENDPOINT } ' , data , auth = auth , timeout = IDTAccountAccessor .SCORE_TIMEOUT )
72+ if result .status_code == 200 :
73+ self .base_url = domain
74+ return result .json ()['access_token' ]
75+
76+ raise ValueError ('Access token for IDT API could not be generated. Check your credentials.' )
7577
7678 def get_sequence_scores (self , sequences : list [sbol3 .Sequence ]) -> list :
7779 """Retrieve synthesis complexity scores of sequences from the IDT API
@@ -91,7 +93,7 @@ def get_sequence_scores(self, sequences: list[sbol3.Sequence]) -> list:
9193 results = []
9294 for idx , partition in enumerate (partitions_sequences ):
9395 logging .debug ('Sequence score request %i of %i' , idx + 1 , len (partitions_sequences ))
94- resp = post (IDTAccountAccessor ._SCORE_URL , json = partition , timeout = IDTAccountAccessor .SCORE_TIMEOUT ,
96+ resp = post (f' { self . base_url } { IDTAccountAccessor ._SCORE_ENDPOINT } ' , json = partition , timeout = IDTAccountAccessor .SCORE_TIMEOUT ,
9597 headers = {'Authorization' : 'Bearer {}' .format (self .token ),
9698 'Content-Type' : 'application/json; charset=utf-8' })
9799 response_list = resp .json ()
0 commit comments