if ($ApplyFor == COLLECTION_WORKFLOW_APPLY_IN_ADMIN_ADD )
{
	$DropboxID = $WorkFlowReturnArray['InsertedID'];
}
else
{
	$DropboxID = $WorkFlowReturnArray['EditedID'];
}	

$DropboxInfo = $this->getRowById($CollectionID , $DropboxID);

include_once $_SERVER['DOCUMENT_ROOT'].'/classes/StorageDropbox/src/Dropbox/autoload.php';

$oauth = new Dropbox_OAuth_PEAR($DropboxInfo['Collection_390_3'],$DropboxInfo['Collection_390_4']);

$dropbox = new Dropbox_API($oauth);

try {

$tokens = $oauth->getRequestToken();
$_SESSION['oauth_tokens'] = $tokens;

}
catch(Exception $ex) {
	if ($ApplyFor == COLLECTION_WORKFLOW_APPLY_IN_ADMIN_ADD )
	{
		$DURL = $_SERVER['REQUEST_URI'] . '&eid='.$DropboxID;
	}
	else
	{
		$DURL = $_SERVER['REQUEST_URI'];
	}	
	die('The dropbox settings do not seem to be good. Please <a href="'.$DURL.'">check them and try again</a>. ');
}

header ('Location: '.$oauth->getAuthorizeUrl(urlencode('http://'.$_SERVER['HTTP_HOST'].'/'.ADMIN_APP_DIR.'/admin.php?module_id=11&menu_id=7&collectionid=90&colid=2&dboxid='.$DropboxID)));
die();