     # return channel if it already exists
     return callback null, @channels[pubnubChannelName]  if @channels[pubnubChannelName]
 
-    @authenticate options.authenticate, (err) =>
+    @authenticateWithPubNub options.authenticate, (err) =>
 
       return callback err  if err
 

    # https://www.pivotaltracker.com/story/show/88210800
    @pbNotification = PUBNUB.init options


  syncTime: ->

    @fetchServerTime (timestamp) =>
      @lastSeenOnline = timestamp

    setInterval =>
      @fetchServerTime()
    , 10000


  initLocalStorage: ->
    @localStorage  = kd.getSingleton('localStorageController').storage 'realtime'

    # TODO we can remove this later on
    @localStorage.unsetKey 'isPubnubEnabled'

    # each forbidden channel name is stored in local storage
    # this is used for preventing datadog
    unless @localStorage.getValue 'ForbiddenChannels'
      @localStorage.setValue 'ForbiddenChannels', {}


  initAuthentication: ->
    @authenticated = false

    realtimeToken = kookies.get('realtimeToken')

    if realtimeToken?
      @setAuthToken realtimeToken
      @authenticated = yes

      return

    # in case of realtime token does not exist, fetch it from Gatekeeper
    options = { endPoint : '/api/gatekeeper/token', data: { id: whoami().socialApiId } }
    @authenticate options, (err) =>

      return kd.warn err  if err



        return  unless messages?.length and Array.isArray(messages)

        @handlePubNubMessage message, channel  for message in messages

        # since the maximum message limit is 100, we are making a recursive call here
        if messages.length is limit
          historyOptions.start = end
          @fetchChannelHistoryFromPubNub { channel, timestamp: end }
      err: (err) -> kd.warn "Could not fetch history #{err.message}"  unless err

    bo.on 'backoff', -> pb.history historyOptions
