Interface LoginMethod

  • All Known Implementing Classes:
    LoginMethodImpl

    public interface LoginMethod
    A LoginMethod is used to specify which method should be used for connecting users to your application. Connecting a user to Gluon CloudLink is initiated by calling the connect URL, for instance in a WebView. The URL will start the connect process on Gluon CloudLink and might redirect the browser to another website, e.g. Facebook. When the connect flow has finished, the browser will finally be redirected to the callback URL. The response from this URL contains information about the connected user as a JSON object.
    • Method Detail

      • getType

        LoginMethod.Type getType()
        Returns the type of the LoginMethod and defines which service will be used for connecting Gluon CloudLink users.
        Returns:
        the type of the LoginMethod.
      • getProperty

        Optional<String> getProperty​(String key)
        Return the value of a custom property of the LoginMethod. Returns Optional.empty() if no property exists with the given key.
        Parameters:
        key - the key of the property to look up
        Returns:
        an Optional string containing the value of the property that matches the given key
      • getConnectUrl

        String getConnectUrl()
        Constructs the URL that needs to be called to initiate the connect flow for this login method on Gluon CloudLink. The URL can be loaded into a WebView to start the flow.
        Returns:
        a string representing a URL to initiate the connect flow.
      • getCallbackUrl

        String getCallbackUrl()
        Constructs the URL that identifies the callback URL that will be called on Gluon CloudLink as the final step in the connect flow. When the location property of a WebView's WebEngine starts with the callback URL, you know that the connect flow has finished.
        Returns:
        a string representing the callback URL that indicates the end of the connect flow.
      • getLoginUrl

        RestClient getLoginUrl​(String username,
                               String password)
        Returns a configured instance of a RestClient that must be used when verifying the login credentials of a user when authenticating with the LoginMethod.Type.PASSWORD login method. The RestClient is configured as an HTTP POST request with the following form parameters:
        • username: the username of the user that was used when signing up
        • password: the password of the user
        The HTTP response for this RestClient is a JSON object that contains an action, an optional user and an optional message. The action is a string containing one of the following values: CONNECT or FAILURE. The user is available when the action equals to CONNECT. Otherwise only the message field is available, explaining the reason of the failure in more detail.
        Parameters:
        username - the username of the user that was used when signing up
        password - the password of the user
        Returns:
        the RestClient to use for verifying login credentials of a user
      • getSignUpUrl

        RestClient getSignUpUrl​(String name,
                                String username,
                                String password)
        Returns a configured instance of a RestClient that must be used when signing up a new user that is authenticating with the LoginMethod.Type.PASSWORD login method. The RestClient is configured as an HTTP POST request with the following form parameters:
        • name: the full name of the user that is signing up (optional)
        • username: the username of the user
        • password: the password of the user
        The username and password or both mandatory fields, as they are used to verify a user when logging in. The username must therefor also be unique across the application. The HTTP response for this RestClient is a JSON object that contains an action, an optional user and an optional message. The action is a string containing one of the following values: CONNECT or FAILURE. The user is available when the action equals CONNECT. Otherwise only the message field is available, explaining the reason of the failure in more detail.
        Parameters:
        name - the full name of the user that is signing up
        username - the username of the user, used for future logins
        password - the password of the user
        Returns:
        the RestClient to use for signing up a new user