diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index c96b21a855..5410bcc55d 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -27,42 +27,45 @@ internal OAuth(string clientId, string clientSecret, string endpoint) internal bool AuthenticateWithLogin(string username, string password) { - var req = new AccessTokenRequestPassword(username, password) + using (var req = new AccessTokenRequestPassword(username, password) { Url = $@"{endpoint}/oauth/token", Method = HttpMethod.POST, ClientId = clientId, ClientSecret = clientSecret - }; - - try + }) { - req.BlockingPerform(); - } - catch - { - return false; - } + try + { + req.BlockingPerform(); + } + catch + { + return false; + } - Token = req.ResponseObject; - return true; + Token = req.ResponseObject; + return true; + } } internal bool AuthenticateWithRefresh(string refresh) { try { - var req = new AccessTokenRequestRefresh(refresh) + using (var req = new AccessTokenRequestRefresh(refresh) { Url = $@"{endpoint}/oauth/token", Method = HttpMethod.POST, ClientId = clientId, ClientSecret = clientSecret - }; - req.BlockingPerform(); + }) + { + req.BlockingPerform(); - Token = req.ResponseObject; - return true; + Token = req.ResponseObject; + return true; + } } catch {