Move getAccessToken logic to the connection
[potlatch2.git] / net / systemeD / potlatch2 / save / SaveManager.as
index 1a72797ac61cd69272f753f5a01b5db4b6a1b96f..77e4f33428cc65596772063a24f14d77456c42ca 100644 (file)
@@ -30,10 +30,11 @@ package net.systemeD.potlatch2.save {
         }
 
         private function save(callback:Function):void {
+            var conn:Connection = Connection.getConnectionInstance();
             if ( consumer == null )
                 consumer = getConsumer();
             if ( accessToken == null )
-                accessToken = getAccessToken();
+                accessToken = conn.getAccessToken(SharedObject.getLocal("access_token").data);
         
             if ( accessToken == null )
                 getNewToken(callback);
@@ -41,22 +42,6 @@ package net.systemeD.potlatch2.save {
                 callback();
         }
 
-        private function getAccessToken():OAuthToken {
-            var key:String = Connection.getParam("oauth_token", null);
-            var secret:String = Connection.getParam("oauth_token_secret", null);
-            
-            if ( key == null || secret == null ) {
-                var data:Object = SharedObject.getLocal("access_token").data;
-                key = data["oauth_token"];
-                secret = data["oauth_token_secret"];
-            }
-            
-            if ( key == null || secret == null )
-                return null;
-            else    
-                return new OAuthToken(key, secret);
-        }
-
         private function getConsumer():OAuthConsumer {
             var key:String = Connection.getParam("oauth_consumer_key", null);
             var secret:String = Connection.getParam("oauth_consumer_secret", null);