mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-01 12:41:24 +12:00
Code refactoring
This commit is contained in:
parent
09500ebaa8
commit
59b30f7062
|
@ -3044,19 +3044,7 @@ private void txtGfycatTitle_TextChanged(object sender, EventArgs e)
|
||||||
private async void oauth2YouTube_OpenButtonClicked()
|
private async void oauth2YouTube_OpenButtonClicked()
|
||||||
{
|
{
|
||||||
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
|
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
|
||||||
GoogleOAuth2 oauthGoogle = new YouTube(oauth).OAuth2;
|
Config.YouTubeOAuth2Info = await OAuth2Loopback(new YouTube(oauth).OAuth2);
|
||||||
OAuthListener listener = new OAuthListener(oauthGoogle);
|
|
||||||
bool result = await listener.ConnectAsync();
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Config.YouTubeOAuth2Info = listener.OAuth.AuthInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Config.YouTubeOAuth2Info = null;
|
|
||||||
}
|
|
||||||
this.ForceActivate();
|
|
||||||
ConfigureOAuthStatus(oauth2YouTube, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void oauth2YouTube_CompleteButtonClicked(string code)
|
private void oauth2YouTube_CompleteButtonClicked(string code)
|
||||||
|
|
|
@ -1084,6 +1084,22 @@ private bool OAuth2Complete(IOAuth2Basic uploader, string code, OAuthControl con
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<OAuth2Info> OAuth2Loopback(IOAuth2Loopback oauth)
|
||||||
|
{
|
||||||
|
OAuthListener listener = new OAuthListener(oauth);
|
||||||
|
bool result = await listener.ConnectAsync();
|
||||||
|
|
||||||
|
this.ForceActivate();
|
||||||
|
ConfigureOAuthStatus(oauth2YouTube, result);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return listener.OAuth.AuthInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private bool OAuth2Refresh(IOAuth2 uploader, OAuthControl oauth2)
|
private bool OAuth2Refresh(IOAuth2 uploader, OAuthControl oauth2)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue