Пример #1
0
 /**
  * Create a BoxSession using a specific box clientId, secret, and redirectUrl. This constructor is
  * not necessary unless an application uses multiple api keys. Note: When setting the userId to
  * null ui will be shown to ask which user to authenticate as if at least one user is logged in.
  * If no user has been stored will show login ui.
  *
  * @param context current context.
  * @param clientId the developer's client id to access the box api.
  * @param clientSecret the developer's secret used to interpret the response coming from Box.
  * @param redirectUrl the developer's redirect url to use for authenticating via Box.
  * @param userId user id to login as or null to login as a new user.
  */
 public BoxSession(
     Context context, String userId, String clientId, String clientSecret, String redirectUrl) {
   mClientId = clientId;
   mClientSecret = clientSecret;
   mClientRedirectUrl = redirectUrl;
   if (SdkUtils.isEmptyString(mClientId) || SdkUtils.isEmptyString(mClientSecret)) {
     throw new RuntimeException(
         "Session must have a valid client id and client secret specified.");
   }
   mApplicationContext = context.getApplicationContext();
   if (!SdkUtils.isEmptyString(userId)) {
     mAuthInfo = BoxAuthentication.getInstance().getAuthInfo(userId, context);
     mUserId = userId;
   }
   if (mAuthInfo == null) {
     mUserId = userId;
     mAuthInfo = new BoxAuthentication.BoxAuthenticationInfo();
   }
   mAuthInfo.setClientId(mClientId);
   setupSession();
 }
Пример #2
0
 /**
  * Construct a new box session object based off of an existing session.
  *
  * @param session session to use as the base.
  */
 protected BoxSession(BoxSession session) {
   this.mApplicationContext = session.mApplicationContext;
   this.mAuthInfo = session.getAuthInfo();
   setupSession();
 }