class Net::IMAP

def auth_mechanisms

Related: #authenticate, #auth_capable?, #capabilities

imap.auth_mechanisms # => []
imap.authenticate("XOAUTH2", username, oauth2_access_token)

imap.auth_mechanisms # => ["PLAIN", "XOAUTH2", "OAUTHBEARER"]
# "AUTH=OAUTHBEARER"]
imap.capabilities # => ["IMAP4REV1", "AUTH=PLAIN", "AUTH=XOAUTH2",
imap.starttls

imap.auth_mechanisms # => []
imap.capabilities # => ["IMAP4REV1", "LOGINDISABLED"]
imap = Net::IMAP.new(hostname, ssl: false)

the connection has authenticated.
servers will drop all AUTH= mechanisms from #capabilities after
This may be different when the connection is cleartext or using TLS. Most

These are derived from the #capabilities with an AUTH= prefix.
Returns the #authenticate mechanisms that the server claims to support.
def auth_mechanisms
  capabilities
    .grep(/\AAUTH=/i)
    .map { _1.delete_prefix("AUTH=") }
end