| Class info |
| public class DriveCredential implements HttpExecuteInterceptor, HttpRequestInitializer, HttpUnsuccessfulResponseHandler |
| Drive authentication class. |
| Type | Name | Desc |
| class | DriveCredential.Builder | Declaration of the DriveCredential.Builder class. |
| @interface | DriveCredential.AccessMethod | Object used to obtain a new access token when the original one expires. |
| Constructor name |
DriveCredential(String unionID, AccessMethod method) Constructor for the DriveCredential class. |
| Return type | Method name |
| void | intercept(HttpRequest request) Intercepts a request to configure request authentication information. |
| boolean | handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) Re-obtains authentication information and sends a new request if a request fails due to an authentication failure. |
| void | initialize(HttpRequest request) Initializes a request. |
| String | getUnionID() Obtains the unique ID of a user. |
| final String | getAccessToken() Obtains an access token. |
| DriveCredential | setAccessToken(String accessToken) Sets an access token. |
| DriveCredential | setExpiresInSeconds(Long expiresIn) Sets the validity period of an access token. |
| final Long | getExpirationTimeMilliseconds() Obtains the validity period of an access token. |
| boolean | refreshToken() Obtains a new access token. |
| DriveCredential | clone() Clones a DriveCredential object. |
| constructor |
| public DriveCredential(String unionID, AccessMethod method) |
| Constructs a DriveCredential object. |
Parameters
| Parameter name | Parameter desc |
| unionID | Union ID, which is a unique user ID obtained after a user signs in using a HUAWEI ID. |
| method | DriveCredential.AccessMethod object, which is used to obtain a new access token when the original one expires. |
| Method |
| public void intercept(HttpRequest request) throws IOException |
| Intercepts a request to configure request authentication information. |
Parameters
| Parameter name | Parameter desc |
| request | HTTP request. |
Throws
| Parameter name | Parameter desc |
| java.io.IOException | I/O exception thrown upon an API call failure. You can use the getMessage() method to obtain the error description. |
| Method |
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) |
| Re-obtains authentication information and sends a new request if a request fails due to an authentication failure. |
Parameters
| Parameter name | Parameter desc |
| request | HTTP request. |
| response | Response to be processed. |
| supportsRetry | Indicates whether an API can be called again upon a call failure. |
Return
| type | desc |
| boolean | Whether an API call is successful. If the API call is successful, true is returned. Otherwise, false is returned. |
| Method |
public void initialize(HttpRequest request) |
| Initializes a request. |
Parameters
| Parameter name | Parameter desc |
| request | HTTP request. |
| Method |
| Method |
public String getUnionID() |
| Obtains the unique ID of a user. |
Return
| type | desc |
| String | Union ID, which is a unique user ID obtained after a user signs in using a HUAWEI ID. |
| Method |
public final String getAccessToken() |
| Obtains an access token. |
Return
| type | desc |
| final String | Authentication information containing the access token. |
| Method |
public DriveCredential setAccessToken(String accessToken) |
| Sets an access token. |
Parameters
| Parameter name | Parameter desc |
| accessToken | Authentication information containing the access token. |
Return
| type | desc |
| DriveCredential | An DriveCredential object. |
| Method |
public DriveCredential setExpiresInSeconds(Long expiresIn) |
| Sets the validity period of an access token. |
Parameters
| Parameter name | Parameter desc |
| expiresIn | Validity period of an access token, in milliseconds. |
Return
| type | desc |
| DriveCredential | An DriveCredential object. |
| Method |
public final Long getExpirationTimeMilliseconds() |
| Obtains the validity period of an access token. |
Return
| type | desc |
| final Long | Validity period of an access token. |
| Method |
public boolean refreshToken() throws IOException |
| Obtains a new access token. |
Return
| type | desc |
| boolean | true: A new access token is successfully obtained. false: A new access token fails to be obtained. |
| Method |
public DriveCredential clone() |
| Clones a DriveCredential object. |
Return
| type | desc |
| DriveCredential | A DriveCredential object. |