How do I use a custom Authenticator with HAClient?
More details on passing credentials to AMPS are available in the FAQ entry How does an application pass credentials to AMPS?.
To use a custom authenticator with HAClient
, you implement the getCurrentAuthenticator
method in your ServerChooser
to return the custom authenticator.
For example, the following C# code returns a custom authenticator stored in the _authenticator variable of the ServerChooser class:
In this case, _authenticator
could be initialized when the server chooser is constructed, set by implementing a property for the authenticator, or in any other way that makes sense for the ServerChooser
.
Likewise, you can implement this function in any way that makes sense. For example, if your authenticator can provide valid credentials through multiple uses, the implementation above works well. If your authenticator objects are designed to only be valid for a single logon (for example, the credentials are only good for a limited amount of time), you could implement this function to construct and return a new Authenticator on every call.
Last updated