Android Oauth Exception with SMTP Transport connect,with android version 2.3 -


I get the following error when I try to start a new Android project. I OS version 2.3 but the same code is working fine on Android 4.0.

  Public SMTP Transport Connect Connect STMTP (string host, int port, string user email, string otheton, boolean debug) exception {multiplier properties = new properties (properties)); Props.put ("mail.smtp.starttls.enable", "true"); Props.put ("mail.smtp.starttls.required", "true"); Props.put ("mail.smtp.sasl.enable", "false"); Session = session. Gate instant (Sahara); Session.setDebug (debug); The final URL name did not use the URL name = null; SMTPTransport transport = new SMTPTransport (session, unused url name); // If the password is non-empty, then SMTP attempts to login. Last string blank password = null; Transport.connect (host, port, user email, empty password); Byte [] response = string.format ("user =% s \ 1auth = bearer% s \ 1 \ 1", user email, othe token) .getBytes (); Feedback = BASE64EncoderStream.encode (feedback); Transport.issueCommand ("AUTH XOAUTH2" + new string (response), 235); Return transportation; }   

Please check the log

  03-21 10: 05: 08.679: w / system. Er (987): javax.mail.MessagingException: 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ == 03-21 October: 05: 08k67 9: W / System.err (987): com.sun.mail.smtp.SMTPTransport.issueCommand (SMTPTransport.java : 1481) on 03-21 October: 05: 08.67 9: W / Systems. Er (987): com.swapmeen.test.GmailOauthSender.connectToSmtp (GMailOauthSender.java:48) 03-21 10: 05: 08.679: W / Systems. Er (987): at com.swapmeen.test .GmailOauthSender.SendMail (GMailOauthSender.java:57) 03-21 10: 05: 08.679: W / Systems. ARR (987): com.swapmeen.test.MainActivity $ 1.run (MainActivity.java:64)    

The error that you are getting

  eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIivic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ ==   

decode the following using the base 64 decoder

  {"status": "400", "plans": "barrier", "scope": "http: //mail.google.com/"}   

It means (as the message is secret as) that the authentication token that you are using should end Or. You have to invalidate it and then get a new one (just request tokens again).

You can invalidate the token like this:

  mAccountManager.invalidateAuthToken ("com. Google", mAuthenticationToken);   

I hope this is useful :)

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -