@@ -32,8 +32,8 @@ class Net::IMAP::SASL::XOAuth2Authenticator
32
32
attr_reader :oauth2_token
33
33
34
34
# :call-seq:
35
- # :call-seq:
36
- # new(username, oauth2_token) -> authenticator
35
+ # new(username, oauth2_token, **) -> authenticator
36
+ # new(username:, oauth2_token:, ** ) -> authenticator
37
37
#
38
38
# Creates an Authenticator for the "+XOAUTH2+" SASL mechanism, as specified by
39
39
# Google[https://developers.google.com/gmail/imap/xoauth2-protocol],
@@ -47,9 +47,15 @@ class Net::IMAP::SASL::XOAuth2Authenticator
47
47
# the service for #username.
48
48
#
49
49
# 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"
53
59
end
54
60
55
61
# :call-seq:
0 commit comments