private async Task LoginWithUsernameAndPassword([NotNull] Credentials credentials) { _log.Write(LogLevel.Debug, "Logging in with credentials"); _github.Credentials = credentials; try { SettingsCache.SaveCredentials(credentials.Login, credentials.Password); var newAuth = new NewAuthorization { Scopes = new[] { "user", "repo" }, Note = "GitHub Visual Studio Extension", NoteUrl = "http://www.alteridem.net" }; var auth = await _github.Authorization.GetOrCreateApplicationAuthentication(Secrets.CLIENT_ID, Secrets.CLIENT_SECRET, newAuth); _log.Write(LogLevel.Info, "Successfully logged in to GitHub"); Token = auth.Token; await LoadData(); } catch (Exception ex) { _log.Write(LogLevel.Warn, "Failed to login", ex); Logout(); throw; } }