Class Consent

  • All Implemented Interfaces:
    Serializable

    public class Consent
    extends Object
    implements Serializable
    Consent provides a mechanism to retrieve an authorization code and exchange it for an OAuth token using the Authorization Code + PKCE flow.

    This class is typically instantiated using an instance of OAuthClient:

    
     OAuthClient client = ...;
     Consent consent = client.initiateConsent();
     

    Web applications or SPAs would redirect a user to the URL returned by getAuthUrl() method and implement a callback handler which calls exchangeCallbackParameters() with the query parameters from the callback to exchange the authorization code for OAuth credentials.

    Native applications can call the launchExternalBrowser() method to open the user's browser to navigate to the authorization page for the current application. A short-lived HTTP server is launched to listen to the callback, and on success, the browser page is closed and the authorization code is collected and exchanged for an OAuth token.

    See Also:
    Serialized Form
    • Method Detail

      • getAuthUrl

        public String getAuthUrl()
      • getVerifier

        public String getVerifier()
      • getState

        public String getState()
      • getTokenUrl

        public String getTokenUrl()
      • getRedirectUrl

        public String getRedirectUrl()
      • getClientId

        public String getClientId()
      • getClientSecret

        public String getClientSecret()
      • launchExternalBrowser

        public SessionCredentials launchExternalBrowser()
                                                 throws IOException
        Launch a browser to collect an authorization code and exchange the code for an OAuth token.
        Returns:
        A SessionCredentials instance representing the retrieved OAuth token.
        Throws:
        IOException - if the webserver cannot be started, or if the browser cannot be opened