Authentication on uploading release assets


#1

I have been unable to successfully upload release assets with integrations. I know my authentication token creation works as I can create new issues with labels, which should require the same permission as uploading assets.

The code I’m building with is nodejs with superagent. The previous code using user oauth code worked without an issue.

Here is the relevant function:

/**
 * postFile
 * Creates a file for a release asset
 * NOTE: uploading uses a different domain than the regular API
 *
 * @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
 *
 * @param {String} owner - GitHub owner
 * @param {String} repo - GitHub repository
 * @param {Number} release - GitHub release ID to publish to
 * @param {String} token - token for GitHub authentication
 *
 * @param {Object} file - file to upload to GitHub
 * @param {String} file.name - name of file on github
 * @param {String} [file.label] - special label to put next to title on GitHub
 * @param {String} file.path - full path to file that should be uploaded
 *
 * @returns {Number} - GitHub asset number
 */
export async function postFile (owner, repo, release, token, file) {
  const filePath = file.path
  delete file.path

  return api
  .post(`https://uploads.github.com/repos/${owner}/${repo}/releases/${release}/assets`)
  .set('Authorization', `token ${token}`)
  .query(file)
  .attach('file', filePath, file.name)
  .then((res) => res.body.id)
  .catch((err, res) => {
    throw errorCheck(err, res, 'postFile', `${owner}/${repo}#${release}`)
  })
}

Using Postman I receive this error, which seems similar to this issue:

{
  "message": "Validation Failed",
  "request_id": "4402AB8A:66A8:3B99185:5806BEF5",
  "documentation_url": "https://developer.github.com/v3",
  "errors": [
    {
      "resource": "ReleaseAsset",
      "code": "custom",
      "field": "uploader_id",
      "message": "uploader_id does not have push access to btkostner/vocal"
    }
  ]
}

#2

Thanks for the report, @btkostner – we’ll take a look and post an update here once we have more news.


#3

Hi @btkostner, we just fixed a bug around this. You should be good to go now. Let us know how you get on, thanks!