Closed idotene closed 11 years ago
I investigated and found out that the message that need to be sent is composed of the following example in base -64: GET https://mail.google.com/mail/b/someuser@example.com/imap/ oauth_consumer_key="anonymous", oauth_nonce="4710307327925439451", oauth_signature="75%2BB63NbW2GdDMaOCEd%2Fy%2Fb%2B0Qk%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1260933683", oauth_token="0j20h2jhgp93hls9hj", oauth_version="1.0"
(taken from https://developers.google.com/google-apps/gmail/oauth_protocol)
Now I'm getting "xm001 NO [ALERT] Invalid credentials (Failure)"
Can you please provide an example of how to construct this message correctly? this is the message I've constructed:
GET https://mail.google.com/mail/b/MyExampleUserForGitHub@gmail.com/imap/ oauth_consumer_key="46431952696543353.apps.googleusercontent.com", oauth_nonce="6f31606ff79d4a9581caefec18883d95", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1354450936", oauth_token="ya29.AHES6ZQOZnssc_psBUCn79HseaR8ruBEc-Ju5CHmnMoa-tQaNg7U1A", oauth_version="1.0", oauth_signature="Bj3PlmdJzTQphYPcJbY33bX3b3M%3D"
Please update ImapClient.cs with the following code:
case AuthMethods.SaslOAuth:
string sasl = "user=" + login + "\x01" + "auth=Bearer " + password + "\x01" + "\x01";
string base64 = Convert.ToBase64String(Encoding.GetBytes(sasl));
command = tag + "AUTHENTICATE XOAUTH2 " + base64;
result = SendCommandGetResponse(command);
break;
Could you send it as a pull request? You can just edit the file in your browser.
Hi,
I when I used the AuthMethods.login method and everything work OK,but when switching to SaslOAuth I can't login.
Please tell me of that's what you did in the token registration process:
1) Redirect the user to https://accounts.google.com/o/oauth2/auth, with scope "https://mail.google.com/" and receiving an authorization code.
2) Send verification request to "https://accounts.google.com" and receiving an access_token in response.
Now, as far as I understand, I need to send the token in the password field in the login process as follows:
ImapClient(Host,userName, token, AuthMethods.SaslOAuth, Port, IsSsl);
Where Port = 993, Host = "imap.gmail.com", IsSsl = true; userName is the mail address, and token is the access_token received from Google.
The response I received is "xm001 NO Invalid SASL argument. x67if3082353weo.114"
Please let me know if you have any idea what is wrong in the process.
Thanks.