#8115 src.fp.o my user token can't create a PR from my fork
Closed: Upstream a month ago by pingou. Opened a month ago by ttomecek.

{
  'error': 'Invalid or expired token. Please visit https://src.fedoraproject.org/settings#api-keys to get or renew your API token.',
  'error_code': 'EINVALIDTOK'
}

my user token has all the possible permissions, but still can't create a PR from my fork

CC @zlopez


Could you point me to the code calling the API?

import os

import ogr

token = os.environ["PAGURE_USER_TOKEN"]

s = ogr.PagureService(token=token)
p = s.get_project(repo="packit", namespace="rpms")

f = p.get_fork()

branch = "0.5.0-master-update"

print(f"Who am I? {s.user.get_username()}")

f.pr_create(
    title="Just testing",
    body="I'm really just testing",
    target_branch="master",
    source_branch=branch
)

ogr is our git-forge library (dnf install python3-ogr), PagureService defaults to src.fp.o

The print-line is the proof that the token is valid.

gives me:

Who am I? ttomecek
{'error': 'Invalid or expired token. Please visit https://src.fedoraproject.org/settings#api-keys to get or renew your API token.', 'error_code': 'EINVALIDTOK'}
Traceback (most recent call last):
  File "create_src_fp_o_pr.py", line 20, in <module>
    source_branch=branch
  File "/home/tt/g/user-cont/ogr/ogr/read_only.py", line 68, in readonly_func
    return func(self, *args, **kwargs)
  File "/home/tt/g/user-cont/ogr/ogr/services/pagure.py", line 547, in pr_create
    "initial_comment": body,
  File "/home/tt/g/user-cont/ogr/ogr/services/pagure.py", line 325, in _call_project_api
    url=request_url, method=method, params=params, data=data
  File "/home/tt/g/user-cont/ogr/ogr/services/pagure.py", line 166, in call_api
    pagure_error=error_msg,
ogr.exceptions.PagureAPIException: Pagure API returned an error when calling `https://src.fedoraproject.org/api/0/fork/ttomecek/rpms/packit/pull-request/new`: Invalid or expired token. Please visit https://src.fedoraproject.org/settings#api-keys to get or renew your API token.

Turned out to be an upstream bug, fixed in https://pagure.io/pagure/pull-request/4576

Speaking with @jlanda we thought we may want to do a .6 release and let @smooge upgrade pkgs01/2 from .4 to .6 directly (since we didn't do the upgrade to .5 yet (was released earlier today))

Metadata Update from @pingou:
- Issue close_status updated to: Upstream
- Issue status updated to: Closed (was: Open)

a month ago

Login to comment on this ticket.

Metadata