21
21
public final class DbxAuthFinish {
22
22
private final String accessToken ;
23
23
private final String userId ;
24
+ private final String accountId ;
24
25
private final /*@Nullable*/ String urlState ;
25
26
26
27
/**
@@ -29,9 +30,10 @@ public final class DbxAuthFinish {
29
30
* @param urlState State data passed in to {@link DbxWebAuth#start} or {@code null} if no state
30
31
* was passed
31
32
*/
32
- public DbxAuthFinish (String accessToken , String userId , /*@Nullable*/ String urlState ) {
33
+ public DbxAuthFinish (String accessToken , String userId , String accountId , /*@Nullable*/ String urlState ) {
33
34
this .accessToken = accessToken ;
34
35
this .userId = userId ;
36
+ this .accountId = accountId ;
35
37
this .urlState = urlState ;
36
38
}
37
39
@@ -47,14 +49,24 @@ public String getAccessToken() {
47
49
48
50
/**
49
51
* Returns the Dropbox user ID of the user who just approved your app for access to their
50
- * Dropbox account.
52
+ * Dropbox account. We use user ID to identify user in API V1.
51
53
*
52
54
* @return Dropbox user ID of user that approved your app for access to their account
53
55
*/
54
56
public String getUserId () {
55
57
return userId ;
56
58
}
57
59
60
+ /**
61
+ * Returns the Dropbox account ID of the user who just approved your app for access to their
62
+ * Dropbox account. We use account ID to identify user in API V2.
63
+ *
64
+ * @return Dropbox account ID of user that approved your app for access to their account
65
+ */
66
+ public String getAccountId () {
67
+ return accountId ;
68
+ }
69
+
58
70
/**
59
71
* Returns the state data you passed in to {@link DbxWebAuth#start}. If you didn't pass
60
72
* anything in, or you used {@link DbxWebAuthNoRedirect}, this will be {@code null}.
@@ -76,7 +88,7 @@ DbxAuthFinish withUrlState(/*@Nullable*/ String urlState) {
76
88
if (this .urlState != null ) {
77
89
throw new IllegalStateException ("Already have URL state." );
78
90
}
79
- return new DbxAuthFinish (accessToken , userId , urlState );
91
+ return new DbxAuthFinish (accessToken , userId , accountId , urlState );
80
92
}
81
93
82
94
/**
@@ -89,6 +101,7 @@ public DbxAuthFinish read(JsonParser parser) throws IOException, JsonReadExcepti
89
101
String accessToken = null ;
90
102
String tokenType = null ;
91
103
String userId = null ;
104
+ String accountId = null ;
92
105
String state = null ;
93
106
94
107
while (parser .getCurrentToken () == JsonToken .FIELD_NAME ) {
@@ -105,6 +118,9 @@ else if (fieldName.equals("access_token")) {
105
118
else if (fieldName .equals ("uid" )) {
106
119
userId = JsonReader .StringReader .readField (parser , fieldName , userId );
107
120
}
121
+ else if (fieldName .equals ("account_id" )) {
122
+ accountId = JsonReader .StringReader .readField (parser , fieldName , accountId );
123
+ }
108
124
else if (fieldName .equals ("state" )) {
109
125
state = JsonReader .StringReader .readField (parser , fieldName , state );
110
126
}
@@ -123,8 +139,9 @@ else if (fieldName.equals("state")) {
123
139
if (tokenType == null ) throw new JsonReadException ("missing field \" token_type\" " , top );
124
140
if (accessToken == null ) throw new JsonReadException ("missing field \" access_token\" " , top );
125
141
if (userId == null ) throw new JsonReadException ("missing field \" uid\" " , top );
142
+ if (accountId == null ) throw new JsonReadException ("missing field \" account_id\" " , top );
126
143
127
- return new DbxAuthFinish (accessToken , userId , state );
144
+ return new DbxAuthFinish (accessToken , userId , accountId , state );
128
145
}
129
146
};
130
147
0 commit comments