Xoauth2 gmail #120

Closed
wants to merge 2 commits into
from

Projects

None yet

6 participants

@bnoguchi

Gmail sends back a response to "AUTHENTICATE XOAUTH2 ..." that is base64 encoded. It needs to be base64 decoded; otherwise, an Error "Unexpected continuation" is generated.

@nickmerwin

+1

@senavinicius

If you could help me...

I'm searching why my php script lo login gmail with oauth2 always returns that {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"} response. And your code contains that. Do you know what I'm doing wrong?

Thanks

@lucasvo
lucasvo commented Apr 3, 2013

I've had the same issue, if you're trying to login with an invalid key, GMail returns a base64 encoded error message:

imap debug { '0': '[connection] Connected to host.' }
imap debug { '0': '\n<== \'* OK Gimap ready for requests from 64.236.139.254 bi1if6484957pbb.30\\r\\n\'\n' }
imap debug { '0': '[parsing incoming] saw untagged OK' }
imap debug { '0': '\n==> A1 CAPABILITY\n' }
imap debug { '0': '\n<== \'* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2\\r\\nA1 OK Thats all she wrote! bi1if6484957pbb.30\\r\\n\'\n' }
imap debug { '0': '[parsing incoming] saw untagged CAPABILITY' }
imap debug { '0': '\n<== \'A1 OK Thats all she wrote! bi1if6484957pbb.30\\r\\n\'\n' }
imap debug { '0': '[parsing incoming] saw tagged response' }
imap debug { '0': '\n==> A2 AUTHENTICATE XOAUTH2 -secret-' }
imap debug { '0': '\n<== \'+ eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==\\r\\n\'\n' }
imap debug { '0': '[parsing incoming] saw continuation response' }

The last message from Gmails server decoded is: {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}

It would be nice to decode this within the library and pass it on to the error handler. What do you think @mscdex ?

@mscdex
Owner
mscdex commented Apr 4, 2013

Can you all try this patch on top of master?

@lucasvo
lucasvo commented Apr 4, 2013

@mscdex yep it works. In case I send an invalid token, the JSON now actually gets returned: Error: {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}]

@lucasvo
lucasvo commented Apr 4, 2013

Although I couldn't directly apply the patch (I'm using the latest trunk of your repo). My changes just in case: https://gist.github.com/lucasvo/62130ea2c7ba00bb7f6f

@mscdex
Owner
mscdex commented Apr 4, 2013

Ah yeah, I forgot to pull some changes first. Added in ce87915. Thanks everyone!

@mscdex mscdex closed this Apr 4, 2013
@zishon89us

@mscdex @lucasvo, hey can help me with this,
{"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}
@senavinicius could u please share how did u solve this,

@mscdex
Owner
mscdex commented May 30, 2013

@zishon89us I'm not very familiar with gmail's oauth2 authentication. Are you sure your access token hasn't expired or something?

@zishon89us

thanx @mscdex, It is working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment