> > Google rewrites the From: header to the user you authorized as because > otherwise, it'd be possible to spoof any other user's email address. I'd be > able to send an email from you to your boss telling him that you quit, that > would be a bad thing :-) > > In order to send an email from [email protected] you'll need to get a > 3-legged OAuth authorized token for [email protected] and use it to > authenticate to smtp.gmail.com. See: > > http://code.google.com/apis/gmail/oauth/ > for details on how SMTP OAuth works. > > Jay > Thanks. This was very helpful. I followed the link and ended up downloading the library and sample app from DotNetOpenAuth, and got that working on my machine. But I don't see how to get from their sample to my requirements. The sample app uses a googleConsumerKey and googleConsumerSecret to retrieve the first 5 contacts from my address book. However, in my app, I need to change the From address to one of the addresses in the address book. Simply retrieving the name and e-mail address is not sufficient. You mentioned that I need to get a 3-legged OAuth token for the From address and use it to authenticate to smtp.gmail.com. Here is the code in the sample app for getting the token: protected void Page_Load(object sender, EventArgs e) { if (this.TokenManager != null) { this.MultiView1.ActiveViewIndex = 1; if (!IsPostBack) { var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); // Is Google calling back with authorization? var accessTokenResponse = google.ProcessUserAuthorization(); if (accessTokenResponse != null) { this.AccessToken = accessTokenResponse.AccessToken; } else if (this.AccessToken == null) { // If we don't yet have access, immediately request it. GoogleConsumer.RequestAuthorization(google, GoogleConsumer.Applications.Contacts); } } } } Is this a 3-legged token? If so, how do I integrate this with the SMTP client in my previous code listing? Thanks. --dan
-- You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-apps-mgmt-apis/-/jK9sQE6K0tQJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.
