Skip to content
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

Invalid token header #21

Open
Dhwani-2410 opened this issue Feb 2, 2023 · 0 comments
Open

Invalid token header #21

Dhwani-2410 opened this issue Feb 2, 2023 · 0 comments

Comments

@Dhwani-2410
Copy link

Dhwani-2410 commented Feb 2, 2023

from varsome_api.client import VarSomeAPIClient
api_key = 'Your token'
api = VarSomeAPIClient(api_key, api_url="https://stable-api.varsome.com")
result = api.lookup('chr7-140453136-A-T',params={'add-source-databases':'gnomad-exomes,refseq-transcripts'},ref_genome='hg19')

HTTPError Traceback (most recent call last)
File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:104, in VarSomeAPIClientBase._make_request(self, path, method, params, json_data)
103 self.logger.info("Content length %s" % len(r.content))
--> 104 r.raise_for_status()
105 return r

File /usr/lib/python3/dist-packages/requests/models.py:940, in Response.raise_for_status(self)
939 if http_error_msg:
--> 940 raise HTTPError(http_error_msg, response=self)

HTTPError: 401 Client Error: Unauthorized for url: https://stable-api.varsome.com/lookup/chr7-140453136-A-T/hg19?add-source-databases=gnomad-exomes%2Crefseq-transcripts

During handling of the above exception, another exception occurred:

VarSomeAPIException Traceback (most recent call last)
Cell In [16], line 4
2 api_key = 'Your token'
3 api = VarSomeAPIClient(api_key, api_url="https://stable-api.varsome.com/")
----> 4 result = api.lookup('chr7-140453136-A-T',params={'add-source-databases':'gnomad-exomes,refseq-transcripts'},ref_genome='hg19')

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:183, in VarSomeAPIClient.lookup(self, query, params, ref_genome)
181 if ref_genome is not None and not self.query_is_variant_id(query):
182 url = self.ref_genome_lookup_path % (query, ref_genome)
--> 183 return self.get(url, params=params)

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:124, in VarSomeAPIClientBase.get(self, path, params)
123 def get(self, path, params=None):
--> 124 response = self._make_request(path, "GET", params=params)
125 return response.json()

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:112, in VarSomeAPIClientBase._make_request(self, path, method, params, json_data)
110 if r.headers["Content-Type"] == "application/json":
111 error_message = response.json().get("detail", None)
--> 112 raise VarSomeAPIException(response.status_code, error_message)
113 raise VarSomeAPIException("", "Unknown http error %s" % e)
114 except Timeout as e:

VarSomeAPIException: 401 (Invalid token header. Token string should not contain spaces.)

The link generated in the output works if I copy and paste it in new browser

HTTPError: 401 Client Error: Unauthorized for url: https://stable-api.varsome.com/lookup/chr7-140453136-A-T/hg19?add-source-databases=gnomad-exomes%2Crefseq-transcripts
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