varsome-api-client-python
varsome-api-client-python copied to clipboard
Invalid token header
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