Skip to content

Commit cc2a624

Browse files
committed
Support Fetching SLT in New DAuth flow and Web flow.
1 parent 7557164 commit cc2a624

File tree

3 files changed

+21
-28
lines changed

3 files changed

+21
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Gradle
22
.gradle/
33
build/
4+
out/
45

56
# Maven build output folder
67
/target/

examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* Will redirect to auth flow if needed
1515
*/
1616
public abstract class DropboxActivity extends AppCompatActivity {
17-
public final static boolean USE_SLT = true;
17+
18+
public final static boolean USE_SLT = false; //If USE_SLT is set to true, our Android example will use our beta feature Short Live Token.
1819

1920
@Override
2021
protected void onResume() {

src/main/java/com/dropbox/core/android/AuthActivity.java

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,7 @@ public class AuthActivity extends Activity {
113113
/**
114114
* Used for internal authentication. You won't ever have to use this.
115115
*/
116-
public static final String EXTRA_AUTH_CODE_CHALLENGE = "CODE_CHALLENGE";
117-
118-
/**
119-
* Used for internal authentication. You won't ever have to use this.
120-
*/
121-
public static final String EXTRA_AUTH_CODE_CHALLENGE_METHOD = "CODE_CHALLENGE_METHOD";
122-
123-
/**
124-
* Used for internal authentication. You won't ever have to use this.
125-
*/
126-
public static final String EXTRA_AUTH_RESPONSE_TYPE = "RESPONSE_TYPE";
127-
128-
/**
129-
* Used for internal authentication. You won't ever have to use this.
130-
*/
131-
public static final String EXTRA_AUTH_TOKEN_ACCESS_TYPE = "TOKEN_ACCESS_TYPE";
116+
public static final String EXTRA_AUTH_QUERY_PARAMS = "AUTH_QUERY_PARAMS";
132117

133118
/**
134119
* The Android action which the official Dropbox app will accept to
@@ -515,15 +500,9 @@ protected void onResume() {
515500

516501
if (mTokenAccessType != null) {
517502
// short live token flow
518-
state = createPKCEStateNonce();
519-
520-
/*
521-
officialAuthIntent.putExtra(EXTRA_AUTH_CODE_CHALLENGE, generateCodeChallenge
522-
(mCodeVerifier));
523-
officialAuthIntent.putExtra(EXTRA_AUTH_CODE_CHALLENGE_METHOD, CODE_CHALLENGE_METHODS);
524-
officialAuthIntent.putExtra(EXTRA_AUTH_TOKEN_ACCESS_TYPE, mTokenAccessType.toString());
525-
officialAuthIntent.putExtra(EXTRA_AUTH_RESPONSE_TYPE, REPONSE_TYPE_CODE);
526-
*/
503+
state = createPKCEStateNonce(); // to support legacy DBApp with V1 flow with
504+
// stormcrow android_use_dauth_version4 turned off.
505+
officialAuthIntent.putExtra(EXTRA_AUTH_QUERY_PARAMS, createExtraQueryParams());
527506
} else {
528507
// Legacy long live token flow
529508
state = createStateNonce();
@@ -675,7 +654,9 @@ private void startWebAuth(String state) {
675654
"k", mAppKey,
676655
"n", alreadyAuthedUid,
677656
"api", mApiType,
678-
"state", state};
657+
"state", state,
658+
"extra_query_params", createExtraQueryParams()
659+
};
679660

680661
String url = DbxRequestUtil.buildUrlWithParams(locale.toString(), mHost.getWeb(), path, params);
681662

@@ -702,8 +683,18 @@ private String createPKCEStateNonce() {
702683
mTokenAccessType.toString());
703684
}
704685

686+
private String createExtraQueryParams() {
687+
return String.format(
688+
"%s=%s&%s=%s&%s=%s&%s=%s",
689+
"code_challenge", mPKCEManager.getCodeChallenge(),
690+
"code_challenge_method", DbxPKCEManager.CODE_CHALLENGE_METHODS,
691+
"token_access_type", mTokenAccessType.toString(),
692+
"response_type", "code"
693+
);
694+
}
695+
705696
private enum TokenType {
706-
OAUTH2("oauth2"),
697+
OAUTH2("oauth2:"),
707698
OAUTH2CODE("oauth2code:");
708699

709700
private String string;

0 commit comments

Comments
 (0)