Class PersonalAccountAuthManager
java.lang.Object
com.amilesend.onedrive.connection.auth.PersonalAccountAuthManager
- All Implemented Interfaces:
AuthManager
Manager that is responsible for obtaining and refreshing tokens to interact with a personal
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.
Example initializing with an auth code:
PersonalAccountAuthManager.builderWithAuthCode()
.httpClient(client) // the OKHttpClient instance
.gsonFactory(gsonFactory) // preconfigured Gson instances
.clientId(clientId) // the client ID of your application
.clientSecret(clientSecret) // the client secret of your application
.redirectUrl(redirectUrl) // the redirect URL for OAUTH flow
.authCode(authCode) // The obtained auth code from initial OAUTH handshake
.buildWithAuthCode();
Example initializing with an AuthInfo (pre-existing refresh token):
PersonalAccountAuthManager.builderWithAuthInfo()
.httpClient(client)
.gsonFactory(gsonFactory)
.clientId(clientId)
.clientSecret(clientSecret)
.redirectUrl(redirectUrl)
.authInfo(authInfo) // Instead of an auth code, an AuthInfo object is used to obtain the refresh token
.buildWithAuthInfo();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
Fields inherited from interface com.amilesend.onedrive.connection.auth.AuthManager
AUTH_CODE_BODY_ARAM, AUTH_CODE_GRANT_TYPE_BODY_PARAM_VALUE, AUTH_TOKEN_URL, CLIENT_ID_BODY_PARAM, CLIENT_SECRET_BODY_PARAM, FORM_DATA_CONTENT_TYPE, GRANT_TYPE_BODY_PARAM, REDIRECT_URI_BODY_PARAM, REFRESH_TOKEN_BODY_PARAM, REFRESH_TOKEN_GRANT_TYPE_BODY_PARAM_VALUE -
Method Summary
Modifier and TypeMethodDescriptionRetrieves 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.Issues a request to refresh the auth tokens and returns the refreshed tokens as aAuthInfo.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amilesend.onedrive.connection.auth.AuthManager
refreshIfExpired, refreshIfExpiredAndFetchFullToken
-
Method Details
-
isAuthenticated
public boolean isAuthenticated()Description copied from interface:AuthManagerDetermines if the current authentication information is up-to-date.- Specified by:
isAuthenticatedin interfaceAuthManager- Returns:
trueif authenticated; else,false
-
isExpired
public boolean isExpired()Description copied from interface:AuthManagerDetermines if the current authentication information is expired.- Specified by:
isExpiredin interfaceAuthManager- Returns:
trueif expired; else,false
-
getAuthInfo
Description copied from interface:AuthManagerRetrieves the current authentication info.- Specified by:
getAuthInfoin interfaceAuthManager- Returns:
- the authentication info
- See Also:
-
getAuthenticatedEndpoint
Description copied from interface:AuthManagerRetrieves the associated endpoint to use for OneDrive operations.- Specified by:
getAuthenticatedEndpointin interfaceAuthManager
-
redeemToken
Description copied from interface:AuthManagerIssues a request to redeem the givenauthCodein order to retrieve access and refresh tokens as aAuthInfo.- Specified by:
redeemTokenin interfaceAuthManager- Parameters:
authCode- the authorization code- Returns:
- the authorization information
- See Also:
-
refreshToken
Description copied from interface:AuthManagerIssues a request to refresh the auth tokens and returns the refreshed tokens as aAuthInfo.- Specified by:
refreshTokenin interfaceAuthManager- Returns:
- the authorization information
- See Also:
-
builderWithAuthCode
-
builderWithAuthInfo
-