Quantcast
Viewing all articles
Browse latest Browse all 4979

GCM Server - Auth Type

Hello everyone.

I'm trying to convert a code of GCM server made in Smack 3.4.1 to 4.1.4.

This is the main part of 3.4.1 code:

 

config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT);

  config.setSecurityMode(SecurityMode.enabled);

  config.setReconnectionAllowed(true);

  config.setRosterLoadedAtLogin(false);

  config.setSendPresence(false);

  config.setSocketFactory(SSLSocketFactory.getDefault());

 

  // NOTE: Set to true to launch a window with information about packets

  // sent and received

  config.setDebuggerEnabled(true);

 

  // -Dsmack.debugEnabled=true

  XMPPConnection.DEBUG_ENABLED = true;

 

  connection = new XMPPConnection(config);

  connection.connect();

 

And this is the code of 4.1.4:

 

XMPPTCPConnectionConfiguration config =

    XMPPTCPConnectionConfiguration.builder()

    .setHost(GCM_SERVER)

        .setPort(GCM_PORT)

        .setServiceName(GCM_SERVER)

        .setCompressionEnabled(false)

    .setSecurityMode(SecurityMode.ifpossible)

    .setSendPresence(false)             

         .setConnectTimeout(30000)

         .setDebuggerEnabled(true)   

         .setSocketFactory(SSLSocketFactory.getDefault())

        

        .build();

   

        connection = new XMPPTCPConnection(config);

       

        //disable Roster as I don't think this is supported by GCM

        Roster roster = Roster.getInstanceFor(connection);

        roster.setRosterLoadedAtLogin(false);

 

        logger.info("Connecting...");

        connection.connect();

 

     connection.login(senderId + "@gcm.googleapis.com" , apiKey);

 

 

The problem is that i can't get this new code to work, it returns me <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><incorrect-encoding/></failure>.

The Smack API is sending this in the login method:

<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='X-OAUTH2'>QURnek16UTNORGMyTVRrd05VQm5ZMjB1WjI5dloyeGxZWEJwY3k1amIyME FRVWw2WVZONVEyVkdVbUptVTNobmVVcHBVbXQ2ZEVWeGFuTnhjbFpwVDBodWNXVnZXbEpO</auth>

 

I searched Google site for information, the login method should send something like that:

<auth mechanism="PLAIN"

xmlns="urn:ietf:params:xml:ns:xmpp-sasl">MTI2MjAwMzQ3OTMzQHByb2plY3RzLmdjbS5hb

mFTeUIzcmNaTmtmbnFLZEZiOW1oekNCaVlwT1JEQTJKV1d0dw==</auth>

 

Looks like the auth type is wrong. How do i change that ?

Can anyone give me a help ?

 

Thanks.


Viewing all articles
Browse latest Browse all 4979

Trending Articles