How to solve 401 authorization error when trying to publish package from gradle

Hi,
This is my first attempt at publishing a package on GitHub.

I set up my project’s build.gradle according to the instructions.

I am using 1. my GitHub username as the username and 2. a PAT with the necessary scopes (I think: delete:packages, repo, write:packages ) as the password. Both are set in my ~/.gradle/gradle.properties, and they look right when I println from the publish task.

However, when I issue gradle publish, the result is:

Execution failed for task ':publishGprPublicationToMavenRepository'.
> Failed to publish publication 'mavenJava' to repository 'GitHubPackages'
   > Could not PUT 'https://maven.pkg.github.com/hansi_b/moss/org/hansi_b/moss/0.2.0/moss-0.2.0.jar'. Received status code 401 from server: Unauthorized

I get the same error if I mess up either the username or the password on purpose. Is there any way to get further information on what is going wrong? Is there some piece of configuration I am missing?

I’d be grateful for any pointers.

Cheers
Hansi

Update (since I cannot edit my post anymore, it seems):

  1. One issue probably was my mistake of using the login name “hansi_b”, when it’s actually “hansi-b”. :grimacing: However, the error persists.
  2. I have verified that with the right user name and PAT, I can clone a repo from the command line.
  3. I have retried this and failed in the same manner with a private repository.

It seems there are 1001 possible reasons for this error. In my case, it was wrongly quoted credentials in my gradle.properties. The properties should a) not be quoted, and b) should quote special chars.
So, instead of
GITHUB_ACTOR='hansi-b'
it has to read
GITHUB_ACTOR=hansi\-b