class Jabber::SASL::Xoauth2


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


Public Instance Methods

auth(password) click to toggle source
# 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

Private Instance Methods

generate_auth(mechanism, text=nil) click to toggle source

**************************************************************************** from the Jingle documentation for CloudPrint

h) Outgoing stanza from Google Cloud Print proxy or printer

****************************************************************************

<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" 
    mechanism="X-OAUTH2" auth:service="chromiumsync" 
    auth:allow-generated-jid="true" 
    auth:client-uses-full-bind-result="true" 
    xmlns:auth="http://www.google.com/talk/protocol/auth">
        {Base-64 encoded authentication data}
</auth>

****************************************************************************

# File lib/kinokero/sasl_xoauth2.rb, line 138
def generate_auth(mechanism, text=nil)

  auth = REXML::Element.new 'auth'
  auth.add_namespace NS_SASL
  auth.attributes['mechanism'] = mechanism
  auth.attributes['auth:service'] = NS_GOOGLE_AUTH_SERVICE
  auth.attributes['auth:allow-generated-jid'] = "true"
  auth.attributes['auth:client-uses-full-bind-result'] = "true"
  auth.attributes['xmlns:auth'] = NS_GOOGLE_AUTH_PROTOCOL
  auth.text = text
  auth
end