///<summary>Throws exceptions if failing to send emails or authenticate with Google.</summary> private static void SendEmailOAuth(BasicEmailAddress address, BasicEmailMessage message) { using GmailApi.GmailService gService = GoogleApiConnector.CreateGmailService(address); try { GmailApi.Data.Message gmailMessage = CreateGmailMsg(address, message); gService.Users.Messages.Send(gmailMessage, address.EmailUsername).Execute(); } catch (GoogleApiException gae) { gae.DoNothing(); //This will bubble up to the UI level and be caught in a copypaste box. throw new Exception("Unable to authenticate with Google: " + gae.Message); } catch (Exception ex) { //This will bubble up to the UI level and be caught in a copypaste box. throw new Exception($"Error sending email with OAuth authorization: {ex.Message}"); } }
public AuthController(GoogleApiConnector api, InventoryContext db) { _api = api; _db = db; }