public class DbxCredential
extends java.lang.Object
DbxClientV2
and DbxTeamClientV2
use
this class to construct clients supporting short-live token and refresh token.Modifier and Type | Field and Description |
---|---|
static long |
EXPIRE_MARGIN
The margin that we think access token is "about to" expire.
|
static JsonReader<DbxCredential> |
Reader |
static JsonWriter<DbxCredential> |
Writer |
Constructor and Description |
---|
DbxCredential(java.lang.String accessToken)
Create a DbxCredential object that doesn't support refreshing.
|
DbxCredential(java.lang.String accessToken,
java.lang.Long expiresAt,
java.lang.String refreshToken,
java.lang.String appKey)
Create a DbxCredential object if your app uses PKCE.
|
DbxCredential(java.lang.String accessToken,
java.lang.Long expiresAt,
java.lang.String refreshToken,
java.lang.String appKey,
java.lang.String appSecret)
Create a DbxCredential object supporting refreshing short live tokens.
|
Modifier and Type | Method and Description |
---|---|
boolean |
aboutToExpire() |
java.lang.String |
getAccessToken()
Returns the OAuth access token to use for authorization with Dropbox servers.
|
java.lang.String |
getAppKey() |
java.lang.String |
getAppSecret() |
java.lang.Long |
getExpiresAt()
Return the millisecond when accessToken is going to expire.
|
java.lang.String |
getRefreshToken()
Return the refresh token which can be used to obtain new access token.
|
DbxRefreshResult |
refresh(DbxRequestConfig requestConfig)
Refresh the short live access token.
|
DbxRefreshResult |
refresh(DbxRequestConfig requestConfig,
java.util.Collection<java.lang.String> scope)
Refresh the short live access token.
|
DbxRefreshResult |
refresh(DbxRequestConfig requestConfig,
DbxHost host,
java.util.Collection<java.lang.String> scope)
This should be used only in internal testing.
|
java.lang.String |
toString() |
public static final long EXPIRE_MARGIN
public static final JsonReader<DbxCredential> Reader
public static final JsonWriter<DbxCredential> Writer
public DbxCredential(java.lang.String accessToken)
accessToken
- Short live token or legacty long live token.public DbxCredential(java.lang.String accessToken, java.lang.Long expiresAt, java.lang.String refreshToken, java.lang.String appKey)
accessToken
- Short-lived access token from OAuth flow.expiresAt
- Expiration time in millisecond from OAuth flow.refreshToken
- Refresh token from OAuth flow.appKey
- You app's client id.to learn what is PKCE.
public DbxCredential(java.lang.String accessToken, java.lang.Long expiresAt, java.lang.String refreshToken, java.lang.String appKey, java.lang.String appSecret)
accessToken
- Short-lived access token from OAuth flow.expiresAt
- Expiration time in millisecond from OAuth flow.refreshToken
- Refresh token from OAuth flowappKey
- You app's client id.appSecret
- You app's client secret.public java.lang.String getAccessToken()
public java.lang.Long getExpiresAt()
public java.lang.String getAppKey()
public java.lang.String getAppSecret()
public java.lang.String getRefreshToken()
public boolean aboutToExpire()
public DbxRefreshResult refresh(DbxRequestConfig requestConfig, DbxHost host, java.util.Collection<java.lang.String> scope) throws DbxException
refresh(DbxRequestConfig)
but just add host.requestConfig
- request config used to make http request.host
- which host to call, only used in internal testing.scope
- space-delimited scope list. Must be subset of scope in current oauth2 grant.DbxOAuthException
- If refresh failed becasue of invalid refresh parameter or
refresh token is revoked.DbxException
- If refresh failed for general errors.public DbxRefreshResult refresh(DbxRequestConfig requestConfig) throws DbxException
requestConfig
- request config used to make http request.DbxOAuthException
- If refresh failed because of invalid refresh parameter or
refresh token is invalid or revoked.DbxException
- If refresh failed for general errors.public DbxRefreshResult refresh(DbxRequestConfig requestConfig, java.util.Collection<java.lang.String> scope) throws DbxException
requestConfig
- request config used to make http request.scope
- Must be a subset of original scopes requested with this OAuth2 grant. You can
use this method to obtain a new short lived token with less access than the
original one.DbxOAuthException
- If refresh failed because of invalid refresh parameter or
refresh token is invalid or revoked.DbxException
- If refresh failed for general errors.public java.lang.String toString()
toString
in class java.lang.Object