public class AndroidAuthSession extends AbstractSession
DropboxAPI. Has methods specific to Android for authenticating
users via the Dropbox app or web site.
AndroidAuthSession session = new AndroidAuthSession(myAppKeys, myAccessType);
// When user wants to link to Dropbox, within an activity:
session.startOAuth2Authentication(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));
Session.AccessType, Session.ProxyInfo| Constructor and Description |
|---|
AndroidAuthSession(AppKeyPair appKeyPair)
Creates a new session to authenticate Android apps with the given app
key pair.
|
AndroidAuthSession(AppKeyPair appKeyPair,
AccessTokenPair accessTokenPair)
Creates a new session to authenticate Android apps with the given app
key pair and access type.
|
AndroidAuthSession(AppKeyPair appKeyPair,
Session.AccessType type)
Deprecated.
AccessType is unnecessary. |
AndroidAuthSession(AppKeyPair appKeyPair,
Session.AccessType type,
AccessTokenPair accessTokenPair)
Deprecated.
AccessType is unnecessary. |
AndroidAuthSession(AppKeyPair appKeyPair,
java.lang.String oauth2AccessToken)
Creates a new session to authenticate Android apps with the given app
key pair and access type.
|
| Modifier and Type | Method and Description |
|---|---|
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)
Deprecated.
|
void |
startOAuth2Authentication(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.
|
getAccessTokenPair, getAccessType, getAPIServer, getAppKeyPair, getContentServer, getHttpClient, getLocale, getOAuth2AccessToken, getProxyInfo, getWebServer, isLinked, setAccessTokenPair, setOAuth2AccessToken, setRequestTimeout, signpublic AndroidAuthSession(AppKeyPair appKeyPair, Session.AccessType type)
AccessType is unnecessary.public AndroidAuthSession(AppKeyPair appKeyPair, Session.AccessType type, AccessTokenPair accessTokenPair)
AccessType is unnecessary.public AndroidAuthSession(AppKeyPair appKeyPair)
public AndroidAuthSession(AppKeyPair appKeyPair, AccessTokenPair accessTokenPair)
public AndroidAuthSession(AppKeyPair appKeyPair, java.lang.String oauth2AccessToken)
public void startOAuth2Authentication(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 void startAuthentication(android.content.Context context)
startOAuth2Authentication(android.content.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
onResume() 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()
Sessionunlink in interface Sessionunlink in class AbstractSession