Class OAuthReceiverCallback

java.lang.Object
com.amilesend.onedrive.connection.auth.oauth.OAuthReceiverCallback
All Implemented Interfaces:
HttpHandler

public class OAuthReceiverCallback extends Object implements HttpHandler
HttpServer handler that takes the verifier token passed over from the OAuth provider and stashes it where OAuthReceiver.waitForCode() will find it.
  • Constructor Details

    • OAuthReceiverCallback

      public OAuthReceiverCallback(@NonNull String callbackPath, String successLandingPageUrl, String failureLandingPageUrl)
      Builds a new OAuthReceiverCallback
      Parameters:
      callbackPath - the path to listen for the redirect
      successLandingPageUrl - optional URL for a custom successful landing page
      failureLandingPageUrl - optional URL for a custom failure landing page
  • Method Details

    • handle

      public void handle(HttpExchange httpExchange) throws IOException
      Handles the given request and sets the corresponding redirect status.
      Specified by:
      handle in interface HttpHandler
      Parameters:
      httpExchange - the exchange containing the request from the client
      Throws:
      IOException - if unable to retrieve request information from the exchange
    • waitForCode

      public String waitForCode() throws OAuthReceiverException
      Blocks until the server receives a login result, or the server is stopped by OAuthReceiver.stop(), to return an authorization code.
      Returns:
      authorization code if login succeeds; may return null if the server is stopped by OAuthReceiver.stop()
      Throws:
      OAuthReceiverException - if the server receives an error code (through an HTTP request parameter error)
    • releaseLock

      public void releaseLock()
      Releases the lock.
    • builder

    • getCode

      public String getCode()
      The authorization code.
    • getError

      public String getError()
      The error code.