public class BoxSession extends BoxObject implements BoxAuthentication.AuthListener
| Modifier and Type | Field and Description |
|---|---|
protected BoxAuthentication.BoxAuthenticationInfo |
mAuthInfo |
protected java.lang.String |
mClientId |
protected java.lang.String |
mClientRedirectUrl |
protected java.lang.String |
mClientSecret |
| Modifier | Constructor and Description |
|---|---|
protected |
BoxSession(BoxSession session)
Construct a new box session object based off of an existing session.
|
|
BoxSession(android.content.Context context)
When using this constructor, if a user has previously been logged in/stored or there is only one user, this user will be authenticated.
|
|
BoxSession(android.content.Context context,
java.lang.String userId)
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.
|
|
BoxSession(android.content.Context context,
java.lang.String userId,
java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String redirectUrl)
Create a BoxSession using a specific box clientId, secret, and redirectUrl.
|
| Modifier and Type | Method and Description |
|---|---|
BoxFutureTask<BoxSession> |
authenticate() |
protected BoxFutureTask<BoxSession> |
authenticate(boolean viaBoxApp) |
protected BoxFutureTask<BoxSession> |
authenticateUsingBoxApp()
Authenticate the user using the box application if installed.
|
android.content.Context |
getApplicationContext() |
BoxAuthentication.BoxAuthenticationInfo |
getAuthInfo() |
java.lang.String |
getClientId()
Returns the associated client id.
|
java.lang.String |
getClientSecret()
Returns the associated client secret.
|
java.lang.String |
getRedirectUrl() |
BoxSharedLinkSession |
getSharedLinkSession(java.lang.String sharedLinkUri)
Create a shared link session based off of the current session.
|
BoxUser |
getUser() |
java.lang.String |
getUserAgent() |
java.lang.String |
getUserId() |
BoxFutureTask<BoxSession> |
logout()
Logout the currently authenticated user.
|
void |
onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info)
Called when this user has logged in.
|
void |
onAuthFailure(BoxAuthentication.BoxAuthenticationInfo info,
java.lang.Exception ex)
Called when a failure occurs trying to authenticate or refresh.
|
void |
onLoggedOut(BoxAuthentication.BoxAuthenticationInfo info,
java.lang.Exception ex) |
void |
onRefreshed(BoxAuthentication.BoxAuthenticationInfo info)
Called when this session has been refreshed with new authentication info.
|
BoxFutureTask<BoxSession> |
refresh()
Refresh authentication information associated with this session.
|
void |
setSessionAuthListener(BoxAuthentication.AuthListener listener) |
protected void |
setupSession() |
protected void |
setUserId(java.lang.String userId) |
protected java.lang.String mClientId
protected java.lang.String mClientSecret
protected java.lang.String mClientRedirectUrl
protected BoxAuthentication.BoxAuthenticationInfo mAuthInfo
public BoxSession(android.content.Context context)
context - current context.public BoxSession(android.content.Context context,
java.lang.String userId)
userId - user id to login as or null to login a new user.context - current context.public BoxSession(android.content.Context context,
java.lang.String userId,
java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String redirectUrl)
context - current context.clientId - the developer's client id to access the box api.clientSecret - the developer's secret used to interpret the response coming from Box.redirectUrl - the developer's redirect url to use for authenticating via Box.userId - user id to login as or null to login as a new user.protected BoxSession(BoxSession session)
session - session to use as the base.public android.content.Context getApplicationContext()
public void setSessionAuthListener(BoxAuthentication.AuthListener listener)
listener - listener to notify when authentication events (authentication, refreshing, and their exceptions) occur.protected void setupSession()
public BoxUser getUser()
public java.lang.String getUserId()
protected void setUserId(java.lang.String userId)
public BoxAuthentication.BoxAuthenticationInfo getAuthInfo()
public java.lang.String getUserAgent()
public BoxFutureTask<BoxSession> authenticate()
protected BoxFutureTask<BoxSession> authenticateUsingBoxApp()
protected BoxFutureTask<BoxSession> authenticate(boolean viaBoxApp)
public BoxFutureTask<BoxSession> logout()
public BoxFutureTask<BoxSession> refresh()
public BoxSharedLinkSession getSharedLinkSession(java.lang.String sharedLinkUri)
sharedLinkUri - The url of the shared link.public void onRefreshed(BoxAuthentication.BoxAuthenticationInfo info)
onRefreshed in interface BoxAuthentication.AuthListenerinfo - the latest info from a successful refresh.public void onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info)
onAuthCreated in interface BoxAuthentication.AuthListenerinfo - the latest info from going through the login flow.public void onAuthFailure(BoxAuthentication.BoxAuthenticationInfo info, java.lang.Exception ex)
onAuthFailure in interface BoxAuthentication.AuthListenerinfo - The last authentication information available, before the exception.ex - the exception that occurred.public void onLoggedOut(BoxAuthentication.BoxAuthenticationInfo info, java.lang.Exception ex)
onLoggedOut in interface BoxAuthentication.AuthListenerpublic java.lang.String getClientId()
public java.lang.String getClientSecret()
public java.lang.String getRedirectUrl()