Interface AuthManager
- All Known Implementing Classes:
BusinessAccountAuthManager,PersonalAccountAuthManager
public interface AuthManager
The interface that defines the manager that is responsible for obtaining and refreshing tokens
to interact with a OneDrive account. Note: This does not manage the initial stages of the OAUTH request
flow and instead relies on a provided auth code or a pre-existing refresh token.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic AuthInfofetchAuthInfo(okhttp3.OkHttpClient httpClient, okhttp3.Request request) Helper method to dispatch the request to redeem or refresh authorization tokens.Retrieves the associated endpoint to use for OneDrive operations.Retrieves the current authentication info.booleanDetermines if the current authentication information is up-to-date.booleanDetermines if the current authentication information is expired.redeemToken(String authCode) Issues a request to redeem the givenauthCodein order to retrieve access and refresh tokens as aAuthInfo.default voidChecks to see if the current authentication info is expired and refreshes the tokens accordingly.default StringHelper method to refresh authentication if expired and return the full token used in request headers.Issues a request to refresh the auth tokens and returns the refreshed tokens as aAuthInfo.
-
Field Details
-
AUTH_TOKEN_URL
- See Also:
-
FORM_DATA_CONTENT_TYPE
-
CLIENT_ID_BODY_PARAM
- See Also:
-
CLIENT_SECRET_BODY_PARAM
- See Also:
-
REDIRECT_URI_BODY_PARAM
- See Also:
-
AUTH_CODE_BODY_ARAM
- See Also:
-
REFRESH_TOKEN_BODY_PARAM
- See Also:
-
GRANT_TYPE_BODY_PARAM
- See Also:
-
AUTH_CODE_GRANT_TYPE_BODY_PARAM_VALUE
- See Also:
-
REFRESH_TOKEN_GRANT_TYPE_BODY_PARAM_VALUE
- See Also:
-
-
Method Details
-
isAuthenticated
boolean isAuthenticated()Determines if the current authentication information is up-to-date.- Returns:
trueif authenticated; else,false
-
isExpired
boolean isExpired()Determines if the current authentication information is expired.- Returns:
trueif expired; else,false
-
refreshIfExpired
default void refreshIfExpired()Checks to see if the current authentication info is expired and refreshes the tokens accordingly. -
refreshIfExpiredAndFetchFullToken
Helper method to refresh authentication if expired and return the full token used in request headers.- Returns:
- the full auth token
-
getAuthInfo
AuthInfo getAuthInfo()Retrieves the current authentication info.- Returns:
- the authentication info
- See Also:
-
getAuthenticatedEndpoint
String getAuthenticatedEndpoint()Retrieves the associated endpoint to use for OneDrive operations. -
redeemToken
Issues a request to redeem the givenauthCodein order to retrieve access and refresh tokens as aAuthInfo.- Parameters:
authCode- the authorization code- Returns:
- the authorization information
- See Also:
-
refreshToken
AuthInfo refreshToken()Issues a request to refresh the auth tokens and returns the refreshed tokens as aAuthInfo.- Returns:
- the authorization information
- See Also:
-
fetchAuthInfo
Helper method to dispatch the request to redeem or refresh authorization tokens.- Parameters:
httpClient- the http clientrequest- the request- Returns:
- the authorization information
-