class Net::IMAP::SASL::XOAuth2Authenticator
See Net::IMAP::SASL::OAuthBearerAuthenticator.
“OAUTHBEARER
”, it is still very widely supported.
Although this mechanism was never standardized and has been obsoleted by
documentation for their scopes.
these scopes are not standardized—consult each service provider’s
with the appropriate OAuth2 scopes to access the user’s services. Most of
This mechanism requires an OAuth2 access token which has been authorized<br><br>Microsoft.
andXOAUTH2
has been documented by
originally created for GMail and widely adopted by hosted email providers.
Authenticator for the “XOAUTH2
” SASL mechanism. This mechanism was
def build_oauth2_string(username, oauth2_token)
def build_oauth2_string(username, oauth2_token) format("user=%s\1auth=Bearer %s\1\1", username, oauth2_token) end
def done?; @done end
The authentication should not succeed unless this returns true, but it
Returns true when the initial client response was sent.
def done?; @done end
def initial_response?; true end
initial_response? -> true
:call-seq:
def initial_response?; true end
def initialize(user = nil, token = nil, username: nil, oauth2_token: nil,
the service for #username.
* #oauth2_token --- An OAuth2.0 access token which is authorized to access
authenticated identity is established for the client with the OAuth token.
_authorization_ identity and not the _authentication_ identity. The
Note that, unlike some other authenticators, +username+ sets the
#authzid --- an alias for #username.
* #username --- the username for the account being accessed.
=== Properties
and Yahoo[https://senders.yahooinc.com/developer/documentation].
Microsoft[https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth]
Google[https://developers.google.com/gmail/imap/xoauth2-protocol],
Creates an Authenticator for the "+XOAUTH2+" SASL mechanism, as specified by
new(authzid:, oauth2_token:, **) -> authenticator
new(username:, oauth2_token:, **) -> authenticator
new(username, oauth2_token, **) -> authenticator
:call-seq:
def initialize(user = nil, token = nil, username: nil, oauth2_token: nil, authzid: nil, secret: nil, **) @username = authzid || username || user or raise ArgumentError, "missing username (authzid)" @oauth2_token = oauth2_token || secret || token or raise ArgumentError, "missing oauth2_token" @done = false end
def process(_data)
Returns the XOAUTH2 formatted response, which combines the +username+
def process(_data) build_oauth2_string(@username, @oauth2_token) ensure @done = true end