Using Google's SMTP server using service account

1,760 views
Skip to first unread message

Malthe Borch

unread,
Feb 27, 2013, 10:05:02 AM2/27/13
to oauth...@googlegroups.com
I'm having trouble authenticating through OAuth2 to Google's SMTP service.

I obtain an `access_token` using `SignedJwtAssertionCredentials`, passing a user and a certificate from a service account:


However, I get the error response:

    {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}

This is a paste of my SMTP session: http://pastie.org/private/h89flddz6njlrvwmrhbfjg.

It's basically "Username and Password not accepted" without much other information.

Google's examples assume that you have an "installed app" and thus a `client_secret` with which you obtain an authorization code through a web-based verification step – or that you've already got an `access_token`. Is there a limitation in Google's SMTP service that you can't use an authorization from a service account?

Here's the example code in Python that I have used as a reference:


Help much appreciated.

\malthe

Breno de Medeiros

unread,
Feb 27, 2013, 1:40:54 PM2/27/13
to oauth...@googlegroups.com
If you are not yest familiar with these sites: https://developers.google.com/google-apps/gmail/oauth_overview and https://developers.google.com/google-apps/gmail/xoauth2_protocol I recommend them as probably this is a case where just checking a reference against your code will flush out the problem.

If you have continuing questions, I recommend you repost this question in stackoverflow using tag #google-oauth since there's a larger community in that forum and it's more likely you will get your question answered quickly.

Breno (Google).



\malthe

--
You received this message because you are subscribed to the Google Groups "Developer Forum for Google API Access using OAuth2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oauth2-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
--Breno

Malthe Borch

unread,
Feb 27, 2013, 2:25:30 PM2/27/13
to oauth...@googlegroups.com
On 27 February 2013 19:40, Breno de Medeiros <br...@google.com> wrote:
> If you are not yest familiar with these sites:
> https://developers.google.com/google-apps/gmail/oauth_overview and
> https://developers.google.com/google-apps/gmail/xoauth2_protocol I recommend
> them as probably this is a case where just checking a reference against your
> code will flush out the problem.

I am familiar and I've checked and double-checked. I also saw this
post on Stackoverflow:

http://stackoverflow.com/questions/14227082/sending-emails-with-gmail-oauth2-and-smtp-python

But to no avail.

If only there was an example in the Google API docs on how to use the
service with a principal, i.e. a service account, and not just a
`client_id` + `client_secret` ("installed app").

I'll repost to Stackoverflow if nothing comes through on this channel.
Thanks for the tip.

\malthe
Reply all
Reply to author
Forward
0 new messages