librelist archives

« back to archive

Google OAuth

Google OAuth

From:
Aashish Patil
Date:
2014-06-29 @ 00:04
Hi -

I am unfortunately still stuck on MailCore 1. Is there any way to support
OAuth tokens on MailCore 1? There does not seem to be a an XOAuth constant
on MailCore 1.

Thanks,
Aashish

Re: [mailcore] Google OAuth

From:
Matt Ronge
Date:
2014-06-30 @ 21:47
The library underneath MailCore 1 and 2 is the same (libetpan), so it 
could be added.  

Pull requests welcome!--
Matt Ronge
http://astro-hq.com
iOS and Mac Apps


On Saturday, June 28, 2014 at 7:04 PM, Aashish Patil wrote:

> Hi - 
> 
> I am unfortunately still stuck on MailCore 1. Is there any way to 
support OAuth tokens on MailCore 1? There does not seem to be a an XOAuth 
constant on MailCore 1. 
> 
> Thanks,
> Aashish
> 
> 
> 

Re: [mailcore] Google OAuth

From:
Aashish Patil
Date:
2014-07-01 @ 04:16
Hi Matt -   

Thanks, I did find the method in libetpan that deals with XOAuth. Now, to 
figure out where and when to make that call.  

Regards,
Aashish

Eπvelope - Get more from your email
http://www.PiEnvelope.com



On Monday, June 30, 2014 at 2:47 PM, Matt Ronge wrote:

> The library underneath MailCore 1 and 2 is the same (libetpan), so it 
could be added.   
>  
> Pull requests welcome!--
> Matt Ronge
> http://astro-hq.com
> iOS and Mac Apps
>  
>  
> On Saturday, June 28, 2014 at 7:04 PM, Aashish Patil wrote:
>  
> > Hi -  
> >  
> > I am unfortunately still stuck on MailCore 1. Is there any way to 
support OAuth tokens on MailCore 1? There does not seem to be a an XOAuth 
constant on MailCore 1.  
> >  
> > Thanks,
> > Aashish
> >  
> >  
> >  
> >  
>  
>  

Re: [mailcore] Google OAuth

From:
Aashish Patil
Date:
2014-10-30 @ 23:36
Hi Matt - 

Sorry it took a long time to get to this. 

Going through the code and it seems like mailimap_login method is getting 
called and not mailimap_login_sasl (which is what seems to recognize oauth
as an auth type). 

For MailCore2: 
MailCore 2 seems to call ->  mailimap_oauth2_authenticate(mImap, 
utf8username, MCUTF8(mOAuth2Token)); 
For non - oauth, MailCore2 calls -> mailimap_authenticate(mImap, "KERBEROS_V4",
                                      MCUTF8(mHostname),
                                      NULL,
                                      NULL,
                                      utf8username, utf8username,
                                      utf8password, NULL/* realm */);




MailCore 1 seems to work around imap_storage a lot - don’t see a lot of 
this in MailCore2. Sorry if this does not make sense but am not 
well-versed with libetpan. 

I have Google OAuth working and have managed to get the AccessToken but 
don’t know where to plug this. From MailCore 2 it seems this should be 
straightforward, basically use the token instead of password. But I need 
to modify MailCore 1 to make the correct libetpan method call. Any 
help/pointers would be appreciated?

Thanks,
Aashish

> On Jun 30, 2014, at 9:16 PM, Aashish Patil <aashishpatil@gmail.com> wrote:
> 
> Hi Matt - 
> 
> Thanks, I did find the method in libetpan that deals with XOAuth. Now, 
to figure out where and when to make that call. 
> 
> Regards,
> Aashish
> 
> Eπvelope - Get more from your email
> http://www.PiEnvelope.com
> 
> 
> On Monday, June 30, 2014 at 2:47 PM, Matt Ronge wrote:
> 
>> The library underneath MailCore 1 and 2 is the same (libetpan), so it 
could be added. 
>> 
>> Pull requests welcome!
>> --
>> Matt Ronge
>> http://astro-hq.com <http://astro-hq.com/>
>> iOS and Mac Apps
>> 
>> On Saturday, June 28, 2014 at 7:04 PM, Aashish Patil wrote:
>> 
>>> Hi - 
>>> 
>>> I am unfortunately still stuck on MailCore 1. Is there any way to 
support OAuth tokens on MailCore 1? There does not seem to be a an XOAuth 
constant on MailCore 1. 
>>> 
>>> Thanks,
>>> Aashish
>> 
> 

Re: [mailcore] Google OAuth

From:
Hoa V. Dinh
Date:
2014-11-06 @ 02:34
If you update libetpan, you can now use “XOAUTH2” as authentication 
mechanism and use the token as the password.  
It would not require a change on mailcore 1.

--  
Hoa V. Dinh


On Thursday, October 30, 2014 at 4:36 PM, Aashish Patil wrote:

> Hi Matt -  
>  
> Sorry it took a long time to get to this.  
>  
> Going through the code and it seems like mailimap_login method is 
getting called and not mailimap_login_sasl (which is what seems to 
recognize oauth as an auth type).  
>  
> For MailCore2:  
> MailCore 2 seems to call ->  mailimap_oauth2_authenticate(mImap, 
utf8username, MCUTF8(mOAuth2Token));  
> For non - oauth, MailCore2 calls -> mailimap_authenticate(mImap, "KERBEROS_V4",
>                                       MCUTF8(mHostname),
>                                       NULL,
>                                       NULL,
>                                       utf8username, utf8username,
>                                     ;   utf8password, NULL/* realm */);
>  
>  
>  
>  
> MailCore 1 seems to work around imap_storage a lot - don’t see a lot of 
this in MailCore2. Sorry if this does not make sense but am not 
well-versed with libetpan.  
>  
> I have Google OAuth working and have managed to get the AccessToken but 
don’t know where to plug this. From MailCore 2 it seems this should be 
straightforward, basically use the token instead of password. But I need 
to modify MailCore 1 to make the correct libetpan method call. Any 
help/pointers would be appreciated?
>  
> Thanks,
> Aashish
>  
> > On Jun 30, 2014, at 9:16 PM, Aashish Patil <aashishpatil@gmail.com 
(mailto:aashishpatil@gmail.com)> wrote:
> > Hi Matt -   
> >  
> > Thanks, I did find the method in libetpan that deals with XOAuth. Now,
to figure out where and when to make that call.  
> >  
> > Regards,
> > Aashish
> >  
> > Eπvelope - Get more from your email
> > http://www.PiEnvelope.com
> >  
> >  
> >  
> > On Monday, June 30, 2014 at 2:47 PM, Matt Ronge wrote:
> >  
> > > The library underneath MailCore 1 and 2 is the same (libetpan), so 
it could be added.   
> > >  
> > > Pull requests welcome!--
> > > Matt Ronge
> > > http://astro-hq.com (http://astro-hq.com/)
> > > iOS and Mac Apps
> > >  
> > >  
> > > On Saturday, June 28, 2014 at 7:04 PM, Aashish Patil wrote:
> > >  
> > > > Hi -  
> > > >  
> > > > I am unfortunately still stuck on MailCore 1. Is there any way to 
support OAuth tokens on MailCore 1? There does not seem to be a an XOAuth 
constant on MailCore 1.  
> > > >  
> > > > Thanks,
> > > > Aashish
> > > >  
> > > >  
> > > >  
> > > >  
> > >  
> > >  
> >  
>  

Re: [mailcore] Google OAuth

From:
Aashish Patil
Date:
2014-11-11 @ 13:51
Thanks for the tip Hoa! 

I was able to get it working with some minimal changes to both libetpan 
and MailCore 1. Have outlined these below. 

IMAP

1. [CTCoreACcount connectToServer…] accepts an enum for authType and not a
string. So I had to add that value in libetpan:
- Added IMAP_AUTH_TYPE_XOAUTH2 to imapdriver_types.h

/* this is the type of IMAP4rev1 authentication */

enum {
  IMAP_AUTH_TYPE_PLAIN,            /* plain text authentication */
  IMAP_AUTH_TYPE_SASL_ANONYMOUS,   /* SASL anonymous */
  IMAP_AUTH_TYPE_SASL_CRAM_MD5,    /* SASL CRAM MD5 */
  IMAP_AUTH_TYPE_SASL_KERBEROS_V4, /* SASL KERBEROS V4 */
  IMAP_AUTH_TYPE_SASL_PLAIN,       /* SASL plain */
  IMAP_AUTH_TYPE_SASL_SCRAM_MD5,   /* SASL SCRAM MD5 */
  IMAP_AUTH_TYPE_SASL_GSSAPI,      /* SASL GSSAPI */
  IMAP_AUTH_TYPE_SASL_DIGEST_MD5,   /* SASL digest MD5 */
  IMAP_AUTH_TYPE_OAUTH2
};


2. Modified connectToServer in [CTCoreAccount] in MailCore 1
if(authType == IMAP_AUTH_TYPE_SASL_CRAM_MD5) {
        auth_type_to_pass = "CRAM-MD5";
    } else if(authType == IMAP_AUTH_TYPE_OAUTH2) {
        auth_type_to_pass = "XOAUTH2";
    }


SMTP
Then there are SMTP modifications. These are a bit of a hack but they work
for now. The SMTP sendMessage and canConnectToServer methods don’t have an
authType parameter. Instead, I converted the ‘useAuth’ one to be an int 
with three values 0 - No auth, 1- Same as Today, 2-OAuth.

1. Added an extra param to [CTSMTP authenticateWithUsername ] message 
called ‘authType’. 

- (BOOL)authenticateWithUsername:(NSString *)username password:(NSString 
*)password server:(NSString *)server authType:(int)authType

2. Modified the implementation of this method in [CTESMTP] to call the 
appropriate method in libetpan.

 //Modified by Aashish to call smtpOauth2Authenticate
    mailsmtp *session = [self resource];
    if(aType == 1) {
        char *authType = "PLAIN";
        
        if (session->auth & MAILSMTP_AUTH_CHECKED) {
            // If the server doesn't support PLAIN but does support the 
older LOGIN,
            // fall back to LOGIN. This can happen with older servers like
Exchange 2003
            if (!(session->auth & MAILSMTP_AUTH_PLAIN) && session->auth & 
MAILSMTP_AUTH_LOGIN) {
                authType = "LOGIN";
            }
        }
        
        ret = mailesmtp_auth_sasl(session, authType, cServer, 
local_ip_port, remote_ip_port,
                                  cUsername, cUsername, cPassword, cServer);
    } else if(aType == 2) {
        ret = mailsmtp_oauth2_authenticate(session, cUsername, cPassword);
    }


Thanks,
Aashish

Eπvelope - http://PiEnvelope.com <http://pienvelope.com/>



> On Nov 5, 2014, at 6:34 PM, Hoa V. Dinh <dinh.viet.hoa@gmail.com> wrote:
> 
> If you update libetpan, you can now use “XOAUTH2” as authentication 
mechanism and use the token as the password.
> It would not require a change on mailcore 1.
> 
> -- 
> Hoa V. Dinh
> 
> On Thursday, October 30, 2014 at 4:36 PM, Aashish Patil wrote:
> 
>> Hi Matt - 
>> 
>> Sorry it took a long time to get to this. 
>> 
>> Going through the code and it seems like mailimap_login method is 
getting called and not mailimap_login_sasl (which is what seems to 
recognize oauth as an auth type). 
>> 
>> For MailCore2: 
>> MailCore 2 seems to call ->  mailimap_oauth2_authenticate(mImap, 
utf8username, MCUTF8(mOAuth2Token)); For non - oauth, MailCore2 calls -> 
mailimap_authenticate(mImap, "KERBEROS_V4",
MCUTF8(mHostname),
>>                           &n bsp;           NULL,
>>                                       NULL,
>>                                       utf8username, utf8username,
>>                                     ;   utf8password, NULL/* realm */);
>> 
>> 
>> 
>> MailCore 1 seems to work around imap_storage a lot - don’t see a lot of
this in MailCore2. Sorry if this does not make sense but am not 
well-versed with libetpan. 
>> 
>> I have Google OAuth working and have managed to get the AccessToken but
don’t know where to plug this. From MailCore 2 it seems this should be 
straightforward, basically use the token instead of password. But I need 
to modify MailCore 1 to make the correct libetpan method call. Any 
help/pointers would be appreciated?
>> 
>> Thanks,
>> Aashish
>> 
>>> On Jun 30, 2014, at 9:16 PM, Aashish Patil <aashishpatil@gmail.com 
<mailto:aashishpatil@gmail.com>> wrote:
>>> 
>>> Hi Matt - 
>>> 
>>> Thanks, I did find the method in libetpan that deals with XOAuth. Now,
to figure out where and when to make that call. 
>>> 
>>> Regards,
>>> Aashish
>>> 
>>> Eπvelope - Get more from your email
>>> http://www.PiEnvelope.com <http://www.pienvelope.com/>
>>> 
>>> 
>>> On Monday, June 30, 2014 at 2:47 PM, Matt Ronge wrote:
>>> 
>>>> The library underneath MailCore 1 and 2 is the same (libetpan), so it
could be added. 
>>>> 
>>>> Pull requests welcome!
>>>> --
>>>> Matt Ronge
>>>> http://astro-hq.com <http://astro-hq.com/>
>>>> iOS and Mac Apps
>>>> 
>>>> On Saturday, June 28, 2014 at 7:04 PM, Aashish Patil wrote:
>>>> 
>>>>> Hi - 
>>>>> 
>>>>> I am unfortunately still stuck on MailCore 1. Is there any way to 
support OAuth tokens on MailCore 1? There does not seem to be a an XOAuth 
constant on MailCore 1. 
>>>>> 
>>>>> Thanks,
>>>>> Aashish
>>>> 
>>> 
>> 
>