mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
Use Dropbox API v1 to get account info for public folder support
This commit is contained in:
parent
b82c386d59
commit
ebea75d076
|
@ -97,6 +97,7 @@ public sealed class Dropbox : FileUploader, IOAuth2Basic
|
|||
private const string URLCreateFolder = URLAPI + "/files/create_folder";
|
||||
private const string URLDelete = URLAPI + "/files/delete";
|
||||
private const string URLMove = URLAPI + "/files/move";
|
||||
private const string URLAccountInfo = "https://api.dropbox.com/1/account/info"; // API v1
|
||||
|
||||
private const string URLPublicDirect = "https://dl.dropboxusercontent.com/u";
|
||||
private const string URLShareDirect = "https://dl.dropboxusercontent.com/s";
|
||||
|
@ -203,6 +204,29 @@ public DropboxAccount GetCurrentAccount()
|
|||
return account;
|
||||
}
|
||||
|
||||
// API v1
|
||||
public DropboxAccountInfo GetAccountInfo()
|
||||
{
|
||||
DropboxAccountInfo account = null;
|
||||
|
||||
if (OAuth2Info.CheckOAuth(AuthInfo))
|
||||
{
|
||||
string response = SendRequest(HttpMethod.GET, URLAccountInfo, headers: GetAuthHeaders());
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
account = JsonConvert.DeserializeObject<DropboxAccountInfo>(response);
|
||||
|
||||
if (account != null)
|
||||
{
|
||||
AccountInfo = account;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
public bool DownloadFile(string path, Stream downloadStream)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
|
||||
|
|
|
@ -468,12 +468,12 @@ public void DropboxAuthComplete(string code)
|
|||
|
||||
if (result)
|
||||
{
|
||||
Config.DropboxAccount = dropbox.GetCurrentAccount();
|
||||
Config.DropboxAccountInfo = dropbox.GetAccountInfo();
|
||||
UpdateDropboxStatus();
|
||||
|
||||
oauth2Dropbox.Status = OAuthLoginStatus.LoginSuccessful;
|
||||
|
||||
if (Config.DropboxAccount != null)
|
||||
if (Config.DropboxAccountInfo != null)
|
||||
{
|
||||
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public void DropboxAuthComplete(string code)
|
|||
}
|
||||
}
|
||||
|
||||
Config.DropboxAccount = null;
|
||||
Config.DropboxAccountInfo = null;
|
||||
UpdateDropboxStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -130,7 +130,7 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
|||
// Dropbox
|
||||
|
||||
public OAuth2Info DropboxOAuth2Info = null;
|
||||
public DropboxAccount DropboxAccount = null;
|
||||
//public DropboxAccount DropboxAccount = null;
|
||||
public string DropboxUploadPath = "Public/ShareX/%y/%mo";
|
||||
public bool DropboxAutoCreateShareableLink = false;
|
||||
public DropboxURLType DropboxURLType = DropboxURLType.Default;
|
||||
|
|
Loading…
Reference in a new issue