Class: Jabber::SASL::Xoauth2

Inherits:
Base
  • Object
show all
Defined in:
lib/kinokero/sasl_xoauth2.rb

Overview


cookie is an OAuth2 access token which you obtained from the anonymous registration flow. this is passed as the “password” to auth


Instance Method Summary collapse

Instance Method Details

#auth(password) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/kinokero/sasl_xoauth2.rb', line 97

def auth(password)

  auth_text = "\x00#{@stream.jid.node}\x00#{password}"
  error = nil

#  ::Twiga.say_warn 'XOAUTH2: ' + auth_text.inspect + "\n"
#  ::Twiga.say_warn 'ENCODED: ' + Base64::strict_encode64(auth_text).inspect + "\n"

  @stream.send(
    generate_auth(
      MECHANISM_XOAUTH2, 
      Base64::strict_encode64(auth_text)
    )
  ) do |reply|
    unless reply.name == 'success'
      error = reply.first_element(nil).name
    end
    true
  end  # do reply handling

  raise error unless error.nil?

end