Class BusinessAccountAuthManager

java.lang.Object
com.amilesend.onedrive.connection.auth.BusinessAccountAuthManager
All Implemented Interfaces:
com.amilesend.client.connection.auth.AuthManager<OneDriveAuthInfo>, OneDriveAuthManager

public class BusinessAccountAuthManager extends Object implements OneDriveAuthManager
Manager that is responsible for obtaining and refreshing tokens to interact with a business OneDrive account for a specific resource. 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:

 BusinessAccountAuthManager authManager = BusinessAccountAuthManager.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
         .resourceId(resourceId) // the specific resource identifier
         .authCode(authCode) // The obtained auth code from initial OAUTH handshake
         .buildWithAuthCode();
 

Once the BusinessAccountAuthManager is created, the next step is to discover available services to connect to and authorize access to a chosen service:

 List services = authManager.getServices();
 authManager.authorizeService(services.get(0));
 

Example initializing with an AuthInfo (pre-existing refresh token):

 BusinessAccountAuthManager authManager = BusinessAccountAuthManager.builderWithAuthInfo()
         .httpClient(client)
         .gsonFactory(gsonFactory)
         .clientId(clientId)
         .clientSecret(clientSecret)
         .redirectUrl(redirectUrl)
         .resourceId(resourceId) // the specific resource identifier
         .authInfo(authInfo) // Instead of an auth code, an AuthInfo object is used to obtain the refresh token
         .buildWithAuthInfo();
 
Note: Existing persisted authInfo is only valid for a single resource. If the user is to access a different resource than the one that that is persisted with the auth tokens, then new access tokens are required and should invoke the builderWithAuthCode() flow.
See Also: