|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.dropbox.client2.session.AbstractSession
com.dropbox.client2.android.AndroidAuthSession
public class AndroidAuthSession
Keeps track of a logged in user and contains configuration options for the
DropboxAPI
. Has methods specific to Android for authenticating
users via the Dropbox app or web site.
A typical authentication flow when no user access token pair is saved is as
follows:
AndroidAuthSession session = new AndroidAuthSession(myAppKeys, myAccessType); // When user wants to link to Dropbox, within an activity: session.startAuthentication(this); // When user returns to your activity, after authentication: if (session.authenticationSuccessful()) { try { session.finishAuthentication(); AccessTokenPair tokens = session.getAccessTokenPair(); // Store tokens.key, tokens.secret somewhere } catch (IllegalStateException e) { // Error handling } }
AndroidAuthSession session = new AndroidAuthSession( myAppKeys, myAccessType, new AccessTokenPair(storedAccessKey, storedAccessSecret));
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.dropbox.client2.session.Session |
---|
Session.AccessType, Session.ProxyInfo |
Constructor Summary | |
---|---|
AndroidAuthSession(AppKeyPair appKeyPair,
Session.AccessType type)
Creates a new session to authenticate Android apps with the given app key pair and access type. |
|
AndroidAuthSession(AppKeyPair appKeyPair,
Session.AccessType type,
AccessTokenPair accessTokenPair)
Creates a new session to authenticate Android apps with the given app key pair and access type. |
Method Summary | |
---|---|
boolean |
authenticationSuccessful()
Returns whether the user successfully authenticated with Dropbox. |
java.lang.String |
finishAuthentication()
Sets up a user's access token and secret in this session when you return to your activity from the Dropbox authentication process. |
void |
startAuthentication(android.content.Context context)
Starts the Dropbox authentication process by launching an external app (either the Dropbox app if available or a web browser) where the user will log in and allow your app access. |
void |
unlink()
Unlinks the session by removing any stored access token and secret. |
Methods inherited from class com.dropbox.client2.session.AbstractSession |
---|
getAccessTokenPair, getAccessType, getAPIServer, getAppKeyPair, getContentServer, getHttpClient, getLocale, getProxyInfo, getWebServer, isLinked, setAccessTokenPair, setRequestTimeout, sign |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AndroidAuthSession(AppKeyPair appKeyPair, Session.AccessType type)
public AndroidAuthSession(AppKeyPair appKeyPair, Session.AccessType type, AccessTokenPair accessTokenPair)
Method Detail |
---|
public void startAuthentication(android.content.Context context)
context
- the Context
which to use to launch the
Dropbox authentication activity. This will typically be an
Activity
and the user will be taken back to that
activity after authentication is complete (i.e., your activity
will receive an onResume()
).
java.lang.IllegalStateException
- if you have not correctly set up the
AuthActivity in your manifest, meaning that the Dropbox app will
not be able to redirect back to your app after auth.public boolean authenticationSuccessful()
public java.lang.String finishAuthentication() throws java.lang.IllegalStateException
onActivityResult()
method, but only
after checking that authenticationSuccessful()
is true
.
java.lang.IllegalStateException
- if authentication was not successful prior
to this call (check with authenticationSuccessful()
.public void unlink()
Session
unlink
in interface Session
unlink
in class AbstractSession
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |