i have tried everything and follow every link but still not succeeding. I want to sign in without using password so i assignged password to nil. if i give correct password user sign in successfully but i have sign in without password and by use of token.. i have client id and name followed console.google tutorial but dont have secret id because it was not available for ios.. this is my code every thing work fine with password but not with token.`
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(self.emailimage)];
NSString *base64String = [imageData base64EncodedString];
AppDelegate *tokenD = [[UIApplication sharedApplication]delegate];
NSString * email =tokenD.username;
NSString * accessToken =tokenD.Dtoken;
NSDate *now = [NSDate date];
double seconds1 = [now timeIntervalSince1970];
NSNumber *seconds = [NSNumber numberWithInteger:seconds1];
MCOSMTPSession * smtpSession = [[MCOSMTPSession alloc] init];
smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.hostname = @"smtp.gmail.com";
smtpSession.port = 465;
smtpSession.username = email; //saved value
smtpSession.password=nil;
smtpSession.connectionType = MCOConnectionTypeTLS;
smtpSession.OAuth2Token = accessToken; //saved value
smtpSession.authType = MCOAuthTypeXOAuth2;
smtpSession.checkCertificateEnabled=NO;
MCOMessageBuilder * builder = [[MCOMessageBuilder alloc] init];
MCOAddress *fromAddress = [MCOAddress addressWithMailbox:email];
MCOAddress *toAddress = [MCOAddress addressWithMailbox:self.to.text];
[[builder header] setFrom:fromAddress];
[[builder header] setTo:@[toAddress]];
NSString *htmlbody1=@"";
[[builder header] setSubject:@"Some subject"];
[builder setHTMLBody:htmlbody1];
MCOAttachment *attachment = [MCOAttachment attachmentWithContentsOfFile:self.filename];
[builder addAttachment:attachment];
[smtpSession setConnectionLogger:^(void * connectionID, MCOConnectionLogType type, NSData * data) {
NSString *response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Response %@",response);
}];
NSData * rfc822Data = [builder data];
MCOSMTPSendOperation *sendOperation = [smtpSession sendOperationWithData:rfc822Data];
[sendOperation start:^(NSError *error) {
if(error) {
NSLog(@"%@ Error sending email:%@", email, error);
} else {
NSLog(@"%@ Successfully sent email!", email);
}
}];
`