atlassian-python-api
atlassian-python-api copied to clipboard
Repo Access Token not Working
I created a repository access token and I ran the below code to get my issues for a repo
from atlassian.bitbucket import Bitbucket
bb = Bitbucket(url='https://api.bitbucket.org/', token='REPO_ACCESS_TOKEN', cloud=True)
bb.get_issues(workspace, repo)
However, I got the error:
can only concatenate str (not "dict") to str
Traceback (most recent call last):
File "~/anaconda3/lib/python3.11/site-packages/atlassian/bitbucket/cloud/base.py", line 116, in raise_for_status
error_msg += "\n" + e["detail"]
~~~~~^~~~~~~~~~~~~
TypeError: can only concatenate str (not "dict") to str
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/anaconda3/lib/python3.11/site-packages/deprecated/classic.py", line 285, in wrapper_function
return wrapped_(*args_, **kwargs_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/anaconda3/lib/python3.11/site-packages/atlassian/bitbucket/__init__.py", line 3297, in get_issues
for p in (
File "~/anaconda3/lib/python3.11/site-packages/atlassian/bitbucket/cloud/repositories/issues.py", line 52, in each
for issue in self._get_paged(None, params=params):
File "~/anaconda3/lib/python3.11/site-packages/atlassian/bitbucket/cloud/base.py", line 71, in _get_paged
response = super(BitbucketCloudBase, self).get(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/anaconda3/lib/python3.11/site-packages/atlassian/rest_client.py", line 288, in get
response = self.request(
^^^^^^^^^^^^^
File "~/anaconda3/lib/python3.11/site-packages/atlassian/rest_client.py", line 260, in request
self.raise_for_status(response)
File "~/anaconda3/lib/python3.11/site-packages/atlassian/bitbucket/cloud/base.py", line 119, in raise_for_status
response.raise_for_status()
File "~/anaconda3/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.bitbucket.org/2.0/repositories/{WORKSPACE}/{TEST}/issues
(I have hidden the workspace name and repo name in the final line)
I got a similar error when running this:
from atlassian.bitbucket import Bitbucket
import requests
s = requests.Session()
s.headers['Authorization'] = 'Bearer REPO_ACCESS_TOKEN'
bb = Bitbucket(url='https://api.bitbucket.org/', session=s', cloud=True)
bb.get_issues(workspace, repo)
@YasirKusay Did you figure out that problem ?
@gonchik , Yes, will post how I did it later