12-09-2020 01:38 PM
I thought I understood the custom Account connect method when using a ValidatableAccount returned a string to display to the user if/when the connect() method succeeds. However, my testing shows me that I can return any string I want and it is NEVER displayed to the user. As such, what is the purpose of the string being returned?
12-09-2020 05:29 PM
@rpatrick00 The Account#connect()
method returns a Generic Type, and can be used to return an authentication String, a Session or Connection object etc. to the Snap code. An example can be found in the Account Configuration section of our Developer Documentation.
For a ValidateableAccount
, which simply extends Account
, the connect()
method is called when the “Validate” button in the Account Settings UI is clicked. Your observation is correct that the return value isn’t used for Account validation, what matters is whether or not the connect()
method returns successfully. The validation is considered successful if a value was returned, and validation fails if the call throws an Exception. You can find more information in the Validating Accounts section.
12-09-2020 05:29 PM
@rpatrick00 The T Account<T>.connect()
method supports Java Generics - you can make it return whatever type you choose (not just a String).
If it is a String, it can be used to get a reference to a token value for example and be used in every request. It could also be a complex object holding a variety of information to be used however you wish, including outputting it in a Document.
12-10-2020 06:51 AM
In my case, “connect” doesn’t actually have any semantic meaning for my custom snaps (since they are sending custom SOAP messages to our legacy system) so I am using connect() to validate the connectivity and credential information used to make a SOAP call (by making a SOAP call). Somehow, I got the idea that I could influence the message that pops up in the UI using the message returned by the connect() method. Clearly, that idea was wrong…