@@ -32,8 +32,8 @@ class Net::IMAP::SASL::XOAuth2Authenticator
3232 attr_reader :oauth2_token
3333
3434 # :call-seq:
35- # :call-seq:
36- # new(username, oauth2_token) -> authenticator
35+ # new(username, oauth2_token, **) -> authenticator
36+ # new(username:, oauth2_token:, ** ) -> authenticator
3737 #
3838 # Creates an Authenticator for the "+XOAUTH2+" SASL mechanism, as specified by
3939 # Google[https://developers.google.com/gmail/imap/xoauth2-protocol],
@@ -47,9 +47,15 @@ class Net::IMAP::SASL::XOAuth2Authenticator
4747 # the service for #username.
4848 #
4949 # See the documentation for each attribute for more details.
50- def initialize ( username , oauth2_token )
51- @username = username
52- @oauth2_token = oauth2_token
50+ def initialize ( user = nil , token = nil , username : nil , oauth2_token : nil , **)
51+ @username = username || user or
52+ raise ArgumentError , "missing username"
53+ @oauth2_token = oauth2_token || token or
54+ raise ArgumentError , "missing oauth2_token"
55+ [ username , user ] . compact . count == 1 or
56+ raise ArgumentError , "conflicting values for username"
57+ [ oauth2_token , token ] . compact . count == 1 or
58+ raise ArgumentError , "conflicting values for oauth2_token"
5359 end
5460
5561 # :call-seq:
0 commit comments