1

I am trying to do something that seems like it should be possible, but I am having immense difficulty determining even that.

We are trying to set up a website that can retrieve emails from a gmail inbox. All that matters is that we retrieve emails from a service that is up 100% of the time, so that no emails are lost.

Gmail seems like the easiest option, as it has api's and documentation.

Here is the problem: in developing the functionality surrounding the email retrieval, I used a test gmail account. Using 0Auth2, I connected to the account. The connection process created a browser popup prompting for consent. I had to manually enter the password to the gmail account and grant access, like an installed app. This was not an issue during development.

However, now we need to deploy it to a server, and I need to figure out how to access some sort of gmail (or alternative?) account purely programmatically--no user prompt.

It seemed like the google service account option would work. So I set that up and was able to authenticate a service account programmatically...there is an issue, however: my calls to the inbox no longer work, since the email address of the service account doesn't seem to be a gmail inbox.

How do I, and is it even possible to, set the service account up so that it has access to a gmail inbox once it is credentialed programmatically (and if I am misspelling programmatically, my bad :)? How do I then access the account? How would I set it up and associate it with the service account (this seems like it would be difficult/not intuitive since I actually use an individual gmail account to set up the service account in the developer's console)...

Any help or insight into this problem...or directions of research...would be really appreciated...

Thanks so much;

(My language is C#--in asp.net)

Unless it is possible to delete emails using IMAP, I think I'm stuck using gmail's api...is it possible to delete with IMAP?

Chris
  • 28,822
  • 27
  • 83
  • 158
  • This is for PHP and not C#, but I use this method to fetch mail via IMAP for some of my scripts: http://davidwalsh.name/gmail-php-imap – doublesharp Jun 26 '15 at 17:34
  • Ok, I might have to figure out a C# way to do that...this 0auth/api stuff...it's a good thing there isn't a train to throw my laptop in front of or something. Thanks man – Chris Jun 26 '15 at 17:40
  • Might want to check this out: http://stackoverflow.com/questions/670183/accessing-imap-in-c-sharp – doublesharp Jun 26 '15 at 18:08

1 Answers1

2

You should use a regular OAuth flow but request off line access.

Jay Lee
  • 13,415
  • 3
  • 28
  • 59