Skip to content

IDT Incorrect Token URL in Documentation — www.idtdna.com returns 500, should use region-specific host (e.g. sg.idtdna.com) #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GeneCodeSavvy opened this issue May 6, 2025 · 3 comments

Comments

@GeneCodeSavvy
Copy link
Collaborator

While working with the IDT API, I encountered an issue with the OAuth2 token endpoint specified in the documentation.

Problem

The docs instruct developers to send token requests to:

https://www.idtdna.com/Identityserver/connect/token

However, this URL consistently returns an HTTP 500 Internal Server Error for me.

Working Solution

After some investigation, I found that using the region-specific subdomain works correctly. In my case:

https://sg.idtdna.com/Identityserver/connect/token

This endpoint successfully returns an access token using the same credentials and request payload.

Screen.Recording.2025-05-05.at.23.57.12.mp4
@GeneCodeSavvy
Copy link
Collaborator Author

I have mailed the IDT team, and will post updates here.

@GeneCodeSavvy
Copy link
Collaborator Author

IDT API team do not have a direct solution for dynamically setting the preferred host.
They have provided the list of supported sub-domains.

Region Subdomain Description
Americas www.idtdna.com North and South America
EMEA eu.idtdna.com Europe, Middle East, and Africa
APAC sg.idtdna.com Asia-Pacific region

Checking for all sub-domains brute force, before erroring out should be a simple solution

class IDTAccountAccessor:
    """Class that wraps access to the IDT API"""

    _SUBDOMAINS = ['https://www.idtdna.com/', 'https://eu.idtdna.com/', 'https://sg.idtdna.com/']
    _TOKEN_ENDPOINT = 'Identityserver/connect/token'
    _SCORE_ENDPOINT = 'api/complexities/screengBlockSequences'


    def __init__(self, username: str, password: str, client_id: str, client_secret: str):
        ....
        self.base_url = None
        self.token = self._get_idt_access_token()

    def _get_idt_access_token(self) -> str:
        ....

        for domain in IDTAccountAccessor._SUBDOMAINS:
            result = post(f'{domain}{IDTAccountAccessor._TOKEN_ENDPOINT}', data, auth=auth, timeout=IDTAccountAccessor.SCORE_TIMEOUT)
            if result.status_code == 200:
                self.base_url = domain
                return result.json()['access_token']

        raise ValueError('Access token for IDT API could not be generated. Check your credentials.')

    def get_sequence_scores(self, sequences: list[sbol3.Sequence]) -> list:
        ....
        for idx, partition in enumerate(partitions_sequences):

            resp = post(f'{self.base_url}{IDTAccountAccessor._SCORE_ENDPOINT}', json=partition, 
timeout=IDTAccountAccessor.SCORE_TIMEOUT,
                        headers={'Authorization': 'Bearer {}'.format(self.token),
                                 'Content-Type': 'application/json; charset=utf-8'})
            response_list = resp.json()

@GeneCodeSavvy
Copy link
Collaborator Author

Any thoughts? @Gonza10V @jakebeal @PrashantVaidyanathan
Should I make a PR? My credentials were failing tests due to this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant