public class Consent extends Object implements Serializable
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.
Modifier and Type | Class and Description |
---|---|
static class |
Consent.Builder |
Modifier and Type | Method and Description |
---|---|
protected void |
desktopBrowser() |
SessionCredentials |
exchange(String code,
String state) |
SessionCredentials |
exchangeCallbackParameters(Map<String,String> query) |
String |
getAuthUrl() |
String |
getClientId() |
String |
getClientSecret() |
String |
getRedirectUrl() |
String |
getState() |
String |
getTokenUrl() |
String |
getVerifier() |
SessionCredentials |
launchExternalBrowser()
Launch a browser to collect an authorization code and exchange the code for an OAuth token.
|
Consent |
setHttpClient(HttpClient hc) |
public Consent setHttpClient(HttpClient hc)
public String getAuthUrl()
public String getVerifier()
public String getState()
public String getTokenUrl()
public String getRedirectUrl()
public String getClientId()
public String getClientSecret()
public SessionCredentials launchExternalBrowser() throws IOException
SessionCredentials
instance representing the retrieved OAuth token.IOException
- if the webserver cannot be started, or if the browser cannot be openedprotected void desktopBrowser() throws IOException
IOException
public SessionCredentials exchangeCallbackParameters(Map<String,String> query)
public SessionCredentials exchange(String code, String state)
Copyright © 2023. All rights reserved.