api / org.gradle.api.artifacts.repositories / AuthenticationSupported / getCredentials

getCredentials

abstract fun getCredentials(): PasswordCredentials

Returns the username and password credentials used to authenticate to this repository.

If no credentials have been assigned to this repository, an empty set of username and password credentials is assigned to this repository and returned.

If you are using a different type of credentials than PasswordCredentials, please use #getCredentials(Class) to obtain the credentials.

Exceptions

IllegalStateException - if the credential type was previously set with #credentials(Class, Action) where the type was not PasswordCredentials

Return
the credentials

@Incubating abstract fun <T : Credentials> getCredentials(credentialsType: Class<T>): T

Returns the credentials of the specified type used to authenticate with this repository.

If no credentials have been assigned to this repository, an empty set of credentials of the specified type is assigned to this repository and returned.

Parameters

credentialsType - type of the credential

Exceptions

IllegalArgumentException - when the credentials assigned to this repository are not assignable to the specified type

Return
The credentials