#4479 Pagure API endpoint to list issues throws invalid token error
Closed: Fixed by pingou. Opened by sayanchowdhury.

The Pagure API endpoint to list issues throws an error when a token is passed through the header but the same works without the header. I tried this with libpagure with passed header for each request throws and error. I tried this with curl and the issue persists.

 curl -H "Authorization: token XYZ" https://stg.pagure.io/api/0/ami-purge-report/issues
{
  "error": "Invalid or expired token. Please visit https://stg.pagure.io/settings#api-keys to get or renew your API token.",
  "error_code": "EINVALIDTOK"
}
 curl https://stg.pagure.io/api/0/ami-purge-report/issues   
{
  "args": {
    "assignee": null,
    "author": null,
    "milestones": [],
    "no_stones": null,
    "order": null,
    "priority": null,
    "since": null,
    "status": null,
    "tags": []
  },
  "issues": [
.....

So the way this work is the following:

When listing issues there may be private issues. If you do not authenticate, you only have the public issues. If you do authenticate you either get the public or the public and private issues depending on your access level.

So if you submit a token, it will check if that token is valid because it assumes you're trying to authenticate. If your token is invalid it will raise this exception.

If you only ever want the public issues: don't specify an "Authorization" header, otherwise, provide a valid token :)

So, I think this works as expected :)
Therefore I'm going to close the ticket, if you disagree, we can re-open and discuss it some more :)

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

Commit 8351c460 fixes this issue

Metadata
Related Pull Requests