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

Google Mail IMAP response with padding makes auth parse error #299

Open
Abdillah opened this issue Jan 3, 2025 · 3 comments
Open

Google Mail IMAP response with padding makes auth parse error #299

Abdillah opened this issue Jan 3, 2025 · 3 comments

Comments

@Abdillah
Copy link

Abdillah commented Jan 3, 2025

Google responded to XOAUTH2 authentication with this base64 string with padding format (==),

S: + eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==

When I use online base64 tool, it reveals this text:

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

The library unfortunately using base64::engine::general_purpose::STANDARD_NO_PAD that unable to parse the response and surfaced the error as error authenticating: Unable to parse authentication response.

@jonhoo
Copy link
Owner

jonhoo commented Jan 5, 2025

Oh interesting — @soywod do you have more insight into this one? Should we switch which base64 engine configuration we use?

@Abdillah
Copy link
Author

Abdillah commented Jan 7, 2025

The response above specifically when failing the authentication. I haven't encounter any other encoded string.

The padding also exists (albeit in client request) in an official documentation:
https://developers.google.com/gmail/imap/xoauth2-protocol

@soywod
Copy link
Contributor

soywod commented Jan 8, 2025

Oh interesting — @soywod do you have more insight into this one? Should we switch which base64 engine configuration we use?

I can only say that imap-codec uses the STANDARD engine, and that I have no issue at app level to decode XOAUTH2 error. For which reasons imap uses the STANDARD_NO_PAD engine?

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

3 participants