@@ -1120,17 +1120,16 @@ def auth_capable?(mechanism)
11201120 # password: proc { password ||= ui.prompt_for_password },
11211121 # oauth2_token: proc { accesstok ||= kms.fresh_access_token },
11221122 # }
1123- # if auth_capable? "OAUTHBEARER"
1124- # imap.authenticate "OAUTHBEARER", **creds # authcid, oauth2_token
1125- # elsif auth_capable? "XOAUTH2"
1126- # imap.authenticate "XOAUTH2", **creds # authcid, oauth2_token
1127- # elsif auth_capable? "SCRAM-SHA-256"
1128- # imap.authenticate "SCRAM-SHA-256", **creds # authcid, password
1129- # elsif auth_capable? "PLAIN"
1130- # imap.authenticate "PLAIN", **creds # authcid, password
1131- # elsif auth_capable? "DIGEST-MD5"
1132- # imap.authenticate "DIGEST-MD5", **creds # authcid, password
1133- # elsif auth_capable? "LOGINDISABLED"
1123+ # mechanism = %w[
1124+ # OAUTHBEARER XOAUTH2
1125+ # SCRAM-SHA-256 SCRAM-SHA-1
1126+ # PLAIN
1127+ # ].find {|m|
1128+ # imap.auth_capable?(m)
1129+ # }
1130+ # if mechanism
1131+ # imap.authenticate mechanism, **creds
1132+ # elsif capable? "LOGINDISABLED"
11341133 # raise "the server has disabled login"
11351134 # else
11361135 # imap.login username, password
0 commit comments