Bonjour,
J'essaye de me connecter à gmail via oAuth.
En ligne de commande, pas de soucis, mais par contre impossible via Java
La source de l'exemple est disponible ici : https://code.google.com/p/google-mai...es/oauth2/?r=3
Dernière modification en 2012 donc peut-être que ce code est obsolète ...
En ligne de commande ça fonctionne :
Avez-vous déjà rencontré ce type de problème ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 openssl s_client -crlf -connect imap.gmail.com:993 A002 AUTHENTICATE XOAUTH2 + monrefreshtokenquiseterminepar__ Response : A002 OK myaddress@gmail.com ForName Name authenticated (Success)
Pour information :
- ça ne marche pas avec le Token "de base" ou avec le refresh token
- voici les logs :
Merci d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle] DEBUG IMAPS: mail.imap.fetchsize: 16384 DEBUG IMAPS: mail.imap.ignorebodystructuresize: false DEBUG IMAPS: mail.imap.statuscachetimeout: 1000 DEBUG IMAPS: mail.imap.appendbuffersize: -1 DEBUG IMAPS: mail.imap.minidletime: 10 DEBUG IMAPS: disable AUTH=LOGIN DEBUG IMAPS: disable AUTH=PLAIN DEBUG IMAPS: enable SASL DEBUG IMAPS: SASL mechanisms allowed: XOAUTH2 DEBUG IMAPS: trying to connect to host "imap.gmail.com", port 993, isSSL true * OK Gimap ready for requests from 195.6.245.82 i1mb40455339wjn A0 CAPABILITY * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN A0 OK Thats all she wrote! i1mb40455339wjn DEBUG IMAPS: AUTH: XOAUTH DEBUG IMAPS: AUTH: XOAUTH2 DEBUG IMAPS: AUTH: PLAIN DEBUG IMAPS: AUTH: PLAIN-CLIENTTOKEN DEBUG IMAPS: protocolConnect login, host=imap.gmail.com, user=myaddress@gmail.com, password=<non-null> DEBUG IMAPS: SASL authentication command trace suppressed DEBUG IMAPS: SASL Mechanisms: DEBUG IMAPS: XOAUTH2 DEBUG IMAPS: DEBUG IMAPS: SASL client XOAUTH2 DEBUG IMAPS: SASL callback length: 1 DEBUG IMAPS: SASL callback 0: javax.security.auth.callback.NameCallback@45258dfd DEBUG IMAPS: SASL no response Exception : -->javax.mail.AuthenticationFailedException: [ALERT] Invalid credentials (Failure) at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:715) at javax.mail.Service.connect(Service.java:364) at com.myproject.MailboxHelper.testMailboxWithOAuth(MailboxHelper.java:179)
Cordialement.
Partager