I'm beginner in kotlin.
I'm try to connect to my http service, which requires authentication.
Have error:
Unresolved reference: Authenticator
How can I set Authenticator?
var url = URL ("https://myURL")
val authenticator = object : Authenticator() {
val passwordAuthentication: PasswordAuthentication?
get() = PasswordAuthentication(
"user",
"password".toCharArray()
)
}
CodePudding user response:
Ensure that you've imported Authenticator
at the top of you Kotlin file. I presume this is java.net.Authenticator that you are trying to use, in which case ensure your Kotlin file looks like this:
import java.net.Authenticator
val authenticator = object : Authenticator() {
val passwordAuthentication: PasswordAuthentication
get() = PasswordAuthentication(
"user",
"password".toCharArray()
)
}
CodePudding user response:
(1) Error: Unresolved reference: PasswordAuthentication