```maven("<https://path/to/dependencies>") { n...
# gradle
n
Copy code
maven("<https://path/to/dependencies>") {
    name = "fooBar"
    credentials(PasswordCredentials::class)
}
Hello I have a password protected remote packages and trying to use
PasswordCredentials
but I only have a
password
not
username
. How do I leave
username
empty and just inject password from
gradle.properties
?
v
How does it work with just a password? I mean with what authentication mechanism? Afair how you wrote it, it only works with basic auth. And basic auth needs a username and a password.
n
I mean username is just empty and the password is a personal access token
a
the PaswordCredentials thing is shortcut - you can get the username and password separately with
providers.gradleProperty("<insert-variable-here>")
You can try this, but I'm not sure this will work without a username...
Copy code
// build.gradle.kts

val fooBarPassword = providers.gradleProperty("fooBarPassword")

repositories { 
  maven("https://...") {
    name = "fooBar"
    credentials {
      username = "" // might be necessary?  
      password = fooBarPassword.get()
    }
  }
}
this answer explains more about `providers.gradleProperty(...)`: https://stackoverflow.com/a/72075210/4161471
👍 1
v
Does the username have to be empty, or can it be anything and is ignored? If the latter, just set it to any value in the properties file.
Or you can try if it works with an empty value too
At least Gradle does not complain with an empty value for the property while it complains if the property is absent, so I'd guess it should just work
g
Why not just pass empty variable, it should work. Empty username is still username for base auth
v
Isn't that what I just suggested? I'm just not sure whether the implementation properly handles empty value, but as it does not complain I guess it does.