Search code examples
c#authenticationgoogle-apigoogle-account

How to check if google/gmail account is real?


I am writing a small application that lets the user get a spreadsheet from his Google docs. I am making a log-in Form that requests a email address and name, and then tries to connect to Google, and to check if the account that was entered is real.

I'm using the spreadsheet API, and there is a class called SpreadsheetsService but it doesn't have any status property; it just throws an exception when I enter a wrong account name.

My questions: Is there a library that returns a Status code for this situation?

Should I check the class SpreadsheetsService and check if an exception was thrown? (I have to use a function from this class to produce this)


Solution

  • bool isValid()
    {
        try
        {
           connect();
        }
        catch
        {
           return false;
        }
    
        return true;
    }