2121public final class DbxAuthFinish {
2222 private final String accessToken ;
2323 private final String userId ;
24+ private final String accountId ;
2425 private final /*@Nullable*/ String urlState ;
2526
2627 /**
@@ -29,9 +30,10 @@ public final class DbxAuthFinish {
2930 * @param urlState State data passed in to {@link DbxWebAuth#start} or {@code null} if no state
3031 * was passed
3132 */
32- public DbxAuthFinish (String accessToken , String userId , /*@Nullable*/ String urlState ) {
33+ public DbxAuthFinish (String accessToken , String userId , String accountId , /*@Nullable*/ String urlState ) {
3334 this .accessToken = accessToken ;
3435 this .userId = userId ;
36+ this .accountId = accountId ;
3537 this .urlState = urlState ;
3638 }
3739
@@ -47,14 +49,24 @@ public String getAccessToken() {
4749
4850 /**
4951 * 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.
5153 *
5254 * @return Dropbox user ID of user that approved your app for access to their account
5355 */
5456 public String getUserId () {
5557 return userId ;
5658 }
5759
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+
5870 /**
5971 * Returns the state data you passed in to {@link DbxWebAuth#start}. If you didn't pass
6072 * anything in, or you used {@link DbxWebAuthNoRedirect}, this will be {@code null}.
@@ -76,7 +88,7 @@ DbxAuthFinish withUrlState(/*@Nullable*/ String urlState) {
7688 if (this .urlState != null ) {
7789 throw new IllegalStateException ("Already have URL state." );
7890 }
79- return new DbxAuthFinish (accessToken , userId , urlState );
91+ return new DbxAuthFinish (accessToken , userId , accountId , urlState );
8092 }
8193
8294 /**
@@ -89,6 +101,7 @@ public DbxAuthFinish read(JsonParser parser) throws IOException, JsonReadExcepti
89101 String accessToken = null ;
90102 String tokenType = null ;
91103 String userId = null ;
104+ String accountId = null ;
92105 String state = null ;
93106
94107 while (parser .getCurrentToken () == JsonToken .FIELD_NAME ) {
@@ -105,6 +118,9 @@ else if (fieldName.equals("access_token")) {
105118 else if (fieldName .equals ("uid" )) {
106119 userId = JsonReader .StringReader .readField (parser , fieldName , userId );
107120 }
121+ else if (fieldName .equals ("account_id" )) {
122+ accountId = JsonReader .StringReader .readField (parser , fieldName , accountId );
123+ }
108124 else if (fieldName .equals ("state" )) {
109125 state = JsonReader .StringReader .readField (parser , fieldName , state );
110126 }
@@ -123,8 +139,9 @@ else if (fieldName.equals("state")) {
123139 if (tokenType == null ) throw new JsonReadException ("missing field \" token_type\" " , top );
124140 if (accessToken == null ) throw new JsonReadException ("missing field \" access_token\" " , top );
125141 if (userId == null ) throw new JsonReadException ("missing field \" uid\" " , top );
142+ if (accountId == null ) throw new JsonReadException ("missing field \" account_id\" " , top );
126143
127- return new DbxAuthFinish (accessToken , userId , state );
144+ return new DbxAuthFinish (accessToken , userId , accountId , state );
128145 }
129146 };
130147
0 commit comments