Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMAIL OAuth2 gives AUTHENTICATIONFAILED #80

Closed
b-jam opened this issue Jan 26, 2016 · 9 comments
Closed

GMAIL OAuth2 gives AUTHENTICATIONFAILED #80

b-jam opened this issue Jan 26, 2016 · 9 comments

Comments

@b-jam
Copy link

b-jam commented Jan 26, 2016

Hello,

I am using python-social-auth.
Its working well and I can login to my site using google.

However, when I follow the docs, and use like this
gmail+ssl://youremailaddress%40yourdomain.com.com:oauth2@imap.gmail.com?archive=Archived
It always gives authentication failed, presumably because the oauth2 password fails.
But why does it even need to use the password? It should be able to grab the auth token from python social auth.

The docs could be missing something?
but in the code, get_connection method seems to always try to use a password

@coddingtonbear
Copy link
Owner

As mentioned in the docs, the password is used if no connection could be established with OAuth (see https://github.com/coddingtonbear/django-mailbox/blob/master/django_mailbox/transports/gmail.py#L11 for details). Given the description you've posted above, It sounds like OAuth is failing for you. Are you sure you've stored your credentials properly with python-social-auth?

@b-jam
Copy link
Author

b-jam commented Jan 26, 2016

You're right, OAuth is failing. I just can't see why
I've tried debugging but all I get is that short error below, which doesn't tell me much.

> /srv/env/myenv/lib/python2.7/site-packages/django_mailbox/transports/gmail.py(57)_connect_oauth()
 -> self.server.authenticate('XOAUTH2', lambda x: auth_string)
(Pdb) n
n
error: error('[...ilure)',)
> /srv/env/myenv/lib/python2.7/site-packages/django_mailbox/transports/gmail.py(57)_connect_oauth()
-> self.server.authenticate('XOAUTH2', lambda x: auth_string)

@b-jam
Copy link
Author

b-jam commented Feb 2, 2016

It was hard to find out why as the error was buried, so I had to deconstruct.
Anyways, configuration issue as I didn't realise it had to be "Other" rather than "Web Application"

The redirect URI in the request: urn:ietf:wg:oauth:2.0:oob can only be used by a Client ID for native application. It is not allowed for the 'WEB' client type. You can create a Client ID for native application in the Credentials section of the Google Developers Console.

@coddingtonbear
Copy link
Owner

Awesome, @pa-jama -- I'm glad you found the answer!

@arun10797
Copy link

I am authenticated with django_social, But i am not able to retrieve the mails from gmail.
I am getting following error.
screenshot from 2018-08-21 16-26-15

@coddingtonbear
Copy link
Owner

I think you might find the answer you're looking for by going to the link the error message is directing you to, @arun10797.

@arun10797
Copy link

I have solved that error but now it is just loading and finally I get timeout error.For web mail.
But for gmail I get authentication failed.

@arun10797
Copy link

I have used %40 instead of @

@sushilkhadka165
Copy link

Error on fetch email from gmail using oauth2 but could be fetched using email and password

image

oauth2 credentials is generated using web because only option available options are

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants