AndroidLibraryForGitHubPackagesDemo icon indicating copy to clipboard operation
AndroidLibraryForGitHubPackagesDemo copied to clipboard

Received status code 403 from server: Forbidden

Open cesarferreira opened this issue 5 years ago • 13 comments

Hi, thanks for your article, it was very enlightening!

Yet, I bumped into something. This is the repo: https://github.com/cesarferreira/android-unique-device-id

I'm trying to upload the github package, I followed your guide and it looks like i'm doing everything right but i keep getting this error:

~/code/github/android-unique-device-id master
❯ ./gradlew assembleRelease publish
> Task :android-unique-device-id:publishBarPublicationToGitHubPackagesRepository FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android-unique-device-id:publishBarPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'bar' to repository 'GitHubPackages'
> Could not PUT 'https://maven.pkg.github.com/cesarferreira/android-unique-device-id/cesarferreira/android-unique-device-id/0.0.1/android-unique-device-id-0.0.1.aar'. Received status code 403 from server: Forbidden

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
59 actionable tasks: 3 executed, 56 up-to-date

my build gradle: https://github.com/cesarferreira/android-unique-device-id/blob/master/android-unique-device-id/build.gradle


def getArtifactId = { ->
  return "android-unique-device-id"
}

publishing {
	publications {
		bar(MavenPublication) {
			groupId 'cesarferreira'
			version "0.0.1"
			artifactId getArtifactId()
			artifact("$buildDir/outputs/aar/${getArtifactId()}-release.aar")
		}
}

repositories {
	maven {
		name = "GitHubPackages"
		url = uri("https://maven.pkg.github.com/cesarferreira/android-unique-device-id")
		credentials {
			username = System.getenv("GITHUB_USER")
			password = System.getenv("GITHUB_TOKEN")
		}
	}
}

I even made a token with ALL permissions to see if those basic permissions weren't enough.

I made sure that the environment variables are there.

Does anything stand out to you that I'm missing? Thanks in advance!

cesarferreira avatar Nov 21 '19 11:11 cesarferreira

Hi, Your implementation works fine. I was able to publish your android library onto my account after replacing the Username and Token and the groupId. Might be the 403 frobidden error is related to SSH / Https.

cesar-android-id

prasad79 avatar Nov 21 '19 13:11 prasad79

what group id did you use? not cesarferreira right?

This is very weird, I even created a token with ALL the permissions and it still didnt work

cesarferreira avatar Nov 21 '19 19:11 cesarferreira

it got uploaded with the cesarferreira groupID, but onto my GitHub (as seen in the attached image on earlier comment). I will delete the package/repo if you have a conflict with the groupID.

The problem is definitely not with the token. My guess, when you are pushing the package onto Github, the servers are not allowing this. if it was the token/credentials, it would show a related message.

prasad79 avatar Nov 22 '19 07:11 prasad79

Please try cloning the project with Https clone and it should work.

prasad79 avatar Nov 22 '19 12:11 prasad79

The same happens :/

image

cesarferreira avatar Nov 22 '19 14:11 cesarferreira

  1. I could reproduce the 403 forbidden error with my Library, while doing a SSH clone. Once I cleanedup the SSH token and did a HTTPS clone the new version of my library was uploaded fine. SSH protocol is not supported for uploading github packages.
  2. I also noticed that 403 errors is also thrown when the version number of the library is the same on Github
  3. Possibly, since I already have uploaded the package with your GroupdID, there is bound to be a 403 Error or similar, again as the groupID and package is already used.

prasad79 avatar Nov 25 '19 13:11 prasad79

@cesarferreira were you able to resolve this issue?

prasad79 avatar Dec 10 '19 14:12 prasad79

Couldn't in the end, opened an issue with github team but they never got back to me, thanks a lot @prasad79. WHen they get back to me I'll let you know what was the problem :)

cesarferreira avatar Dec 11 '19 14:12 cesarferreira

Perfect. Meanwhile I sent a request to the GitHub Support team to delete the package I uploaded with your group ID "cesarferreira.android-unique-device-id" The support team has deleted it and so you should not have any conflicts with it

prasad79 avatar Dec 13 '19 10:12 prasad79

Same here, 403 I couldn't resolve

suale-dev avatar May 12 '21 04:05 suale-dev

@cesarferreira @sua8051 Were you able to resolve the issue?

harishgupta01 avatar Sep 09 '21 10:09 harishgupta01

Same here, 403 I couldn't resolve

amirisback avatar Mar 07 '22 06:03 amirisback

Thank for your article. I have successfully uploaded to library to GT and can see it. However now my problem is using it in another project. I have created a "read" access PAT and using those details (PAT and username) but can't gte gradle to resolve the dependency. I also get 404 when I try browsing the maven.pkg url I am using for the repositories configuration in gradle :(. Any help?

saintjab avatar Aug 09 '22 16:08 saintjab