Package com.databricks.sdk.core.oauth
Class Consent
- java.lang.Object
-
- com.databricks.sdk.core.oauth.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 callsexchangeCallbackParameters()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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConsent.Builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddesktopBrowser()SessionCredentialsexchange(String code, String state)SessionCredentialsexchangeCallbackParameters(Map<String,String> query)StringgetAuthUrl()StringgetClientId()StringgetClientSecret()StringgetRedirectUrl()StringgetState()StringgetTokenUrl()StringgetVerifier()SessionCredentialslaunchExternalBrowser()Launch a browser to collect an authorization code and exchange the code for an OAuth token.ConsentsetHttpClient(HttpClient hc)
-
-
-
Method Detail
-
setHttpClient
public Consent setHttpClient(HttpClient hc)
-
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
SessionCredentialsinstance representing the retrieved OAuth token. - Throws:
IOException- if the webserver cannot be started, or if the browser cannot be opened
-
desktopBrowser
protected void desktopBrowser() throws IOException- Throws:
IOException
-
exchangeCallbackParameters
public SessionCredentials exchangeCallbackParameters(Map<String,String> query)
-
exchange
public SessionCredentials exchange(String code, String state)
-
-