11package com .soundcloud .api ;
22
3- import static com .soundcloud .api .AuthParams .CLIENT_ID ;
4- import static com .soundcloud .api .AuthParams .CLIENT_SECRET ;
5- import static com .soundcloud .api .AuthParams .CODE ;
6- import static com .soundcloud .api .AuthParams .GRANT_TYPE ;
7- import static com .soundcloud .api .AuthParams .REDIRECT_URI ;
8- import static com .soundcloud .api .AuthParams .RESPONSE_TYPE ;
9- import static com .soundcloud .api .AuthParams .USERNAME ;
10-
113import org .apache .http .ConnectionReuseStrategy ;
124import org .apache .http .Header ;
135import org .apache .http .HeaderElement ;
@@ -147,11 +139,11 @@ public ApiWrapper(String clientId,
147139 throw new IllegalArgumentException ("username or password is null" );
148140 }
149141 final Request request = addScope (Request .to (Endpoints .TOKEN ).with (
150- GRANT_TYPE , CloudAPI . PASSWORD ,
142+ GRANT_TYPE , PASSWORD ,
151143 CLIENT_ID , mClientId ,
152144 CLIENT_SECRET , mClientSecret ,
153145 USERNAME , username ,
154- AuthParams . PASSWORD , password ), scopes );
146+ PASSWORD , password ), scopes );
155147 mToken = requestToken (request );
156148 return mToken ;
157149 }
@@ -205,20 +197,20 @@ public Token extensionGrantType(String grantType, String... scopes) throws IOExc
205197 @ Override public Token refreshToken () throws IOException {
206198 if (mToken == null || mToken .refresh == null ) throw new IllegalStateException ("no refresh token available" );
207199 mToken = requestToken (Request .to (Endpoints .TOKEN ).with (
208- GRANT_TYPE , CloudAPI . REFRESH_TOKEN ,
200+ GRANT_TYPE , REFRESH_TOKEN ,
209201 CLIENT_ID , mClientId ,
210202 CLIENT_SECRET , mClientSecret ,
211- AuthParams . REFRESH_TOKEN , mToken .refresh ));
203+ REFRESH_TOKEN , mToken .refresh ));
212204 return mToken ;
213205 }
214206
215207 @ Override public Token exchangeOAuth1Token (String oauth1AccessToken ) throws IOException {
216208 if (oauth1AccessToken == null ) throw new IllegalArgumentException ("need access token" );
217209 mToken = requestToken (Request .to (Endpoints .TOKEN ).with (
218- GRANT_TYPE , OAUTH1_TOKEN ,
210+ GRANT_TYPE , OAUTH1_TOKEN_GRANT_TYPE ,
219211 CLIENT_ID , mClientId ,
220212 CLIENT_SECRET , mClientSecret ,
221- AuthParams . REFRESH_TOKEN , oauth1AccessToken ));
213+ REFRESH_TOKEN , oauth1AccessToken ));
222214 return mToken ;
223215 }
224216
@@ -241,8 +233,8 @@ public Token extensionGrantType(String grantType, String... scopes) throws IOExc
241233 final Request req = Request .to (options .length == 0 ? Endpoints .CONNECT : options [0 ]).with (
242234 REDIRECT_URI , mRedirectUri ,
243235 CLIENT_ID , mClientId ,
244- RESPONSE_TYPE , "code" );
245- if (options .length == 2 ) req .add ("scope" , options [1 ]);
236+ RESPONSE_TYPE , CODE );
237+ if (options .length == 2 ) req .add (SCOPE , options [1 ]);
246238 return getURI (req , false , true );
247239 }
248240
@@ -677,7 +669,7 @@ public void setDefaultAcceptEncoding(String encoding) {
677669 scope .append (scopes [i ]);
678670 if (i < scopes .length -1 ) scope .append (" " );
679671 }
680- request .add ("scope" , scope .toString ());
672+ request .add (SCOPE , scope .toString ());
681673 }
682674 return request ;
683675 }
0 commit comments