44
55package com .flickr4java .flickr .auth ;
66
7+ import com .flickr4java .flickr .Flickr ;
78import com .flickr4java .flickr .FlickrException ;
89import com .flickr4java .flickr .Response ;
910import com .flickr4java .flickr .Transport ;
@@ -171,7 +172,13 @@ public Auth checkToken(Token accessToken) throws FlickrException {
171172 */
172173 public Auth checkToken (String authToken , String tokenSecret ) throws FlickrException {
173174
174- Map <String , String > parameters = constructNonOAuthParameters (authToken , METHOD_CHECK_TOKEN );
175+ // Use TreeMap so keys are automatically sorted alphabetically
176+ Map <String , String > parameters = new TreeMap <String , String >();
177+ parameters .put ("method" , METHOD_CHECK_TOKEN );
178+ parameters .put ("oauth_token" , authToken );
179+ parameters .put (Flickr .API_KEY , apiKey );
180+ // This method call must be signed using Flickr (not OAuth) style signing
181+ parameters .put ("api_sig" , getSignature (sharedSecret , parameters ));
175182
176183 Response response = transportAPI .getNonOAuth (transportAPI .getPath (), parameters );
177184 if (response .isError ()) {
@@ -193,7 +200,12 @@ public Auth checkToken(String authToken, String tokenSecret) throws FlickrExcept
193200 */
194201 public Token exchangeAuthToken (String authToken ) throws FlickrException {
195202
196- Map <String , String > parameters = constructNonOAuthParameters (authToken , METHOD_EXCHANGE_TOKEN );
203+ // Use TreeMap so keys are automatically sorted alphabetically
204+ Map <String , String > parameters = new TreeMap <String , String >();
205+ parameters .put ("method" , METHOD_EXCHANGE_TOKEN );
206+ parameters .put (Flickr .API_KEY , apiKey );
207+ // This method call must be signed using Flickr (not OAuth) style signing
208+ parameters .put ("api_sig" , getSignature (sharedSecret , parameters ));
197209
198210 Response response = transportAPI .getNonOAuth (transportAPI .getPath (), parameters );
199211 if (response .isError ()) {
@@ -205,21 +217,6 @@ public Token exchangeAuthToken(String authToken) throws FlickrException {
205217 return accessToken ;
206218 }
207219
208- /**
209- *
210- * @param authToken
211- * @param method
212- */
213- private Map <String , String > constructNonOAuthParameters (String authToken , String method ) {
214- // Use TreeMap so keys are automatically sorted alphabetically
215- Map <String , String > parameters = new TreeMap <String , String >();
216- parameters .put ("method" , method );
217- parameters .put ("oauth_token" , authToken );
218- // This method call must be signed using Flickr (not OAuth) style signing
219- parameters .put ("api_sig" , getSignature (sharedSecret , parameters ));
220- return parameters ;
221- }
222-
223220 /**
224221 *
225222 * @param response
0 commit comments