Skip to content

Commit 1ad5eb0

Browse files
committed
Fix mobile login issue.
1 parent 9c7fa23 commit 1ad5eb0

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.dropbox.core.android;
22

33
import java.security.SecureRandom;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
46
import java.util.List;
57
import java.util.Locale;
68

@@ -666,15 +668,20 @@ private void startWebAuth(String state) {
666668
// Note that the API treats alreadyAuthUid of 0 and not present equivalently.
667669
String alreadyAuthedUid = (mAlreadyAuthedUids.length > 0) ? mAlreadyAuthedUids[0] : "0";
668670

669-
String[] params = {
670-
"k", mAppKey,
671-
"n", alreadyAuthedUid,
672-
"api", mApiType,
673-
"state", state,
674-
"extra_query_params", createExtraQueryParams()
675-
};
671+
List<String> params = new ArrayList<String>(Arrays.asList(
672+
"k", mAppKey,
673+
"n", alreadyAuthedUid,
674+
"api", mApiType,
675+
"state", state
676+
));
676677

677-
String url = DbxRequestUtil.buildUrlWithParams(locale.toString(), mHost.getWeb(), path, params);
678+
if (mTokenAccessType != null) {
679+
params.add("extra_query_params");
680+
params.add(createExtraQueryParams());
681+
}
682+
683+
String url = DbxRequestUtil.buildUrlWithParams(locale.toString(), mHost.getWeb(), path,
684+
params.toArray(new String [0]));
678685

679686
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
680687
startActivity(intent);
@@ -700,6 +707,11 @@ private String createPKCEStateNonce() {
700707
}
701708

702709
private String createExtraQueryParams() {
710+
if (mTokenAccessType == null) {
711+
throw new IllegalStateException("Extra Query Param should only be used in short live " +
712+
"token flow.");
713+
}
714+
703715
String param = String.format(Locale.US,
704716
"%s=%s&%s=%s&%s=%s&%s=%s",
705717
"code_challenge", mPKCEManager.getCodeChallenge(),
@@ -709,7 +721,7 @@ private String createExtraQueryParams() {
709721
);
710722

711723
if (mScope != null) {
712-
param += String.format(Locale.US, "%s=%s", "scope", mScope);
724+
param += String.format(Locale.US, "&%s=%s", "scope", mScope);
713725
}
714726

715727
return param;

0 commit comments

Comments
 (0)