           if callback?
             callback(data)
     when 'SELECT'
-      $.ajax "#{FUSION_TABLES_URI}/query?sql=#{query}&access_token=#{get_cookie 'access_token'}",
+      $.ajax "#{FUSION_TABLES_URI}/query?sql=#{query}",
         type: 'GET'
         cache: false
         dataType: 'json'
         crossDomain: true
+        beforeSend: (xhr) ->
+          xhr.setRequestHeader('Authorization',"Bearer #{get_cookie 'access_token'}")
         error: (jqXHR, textStatus, errorThrown) ->
           console.log "AJAX Error: #{textStatus}"
         success: (data) ->

FUSION_TABLES_URI = 'https://www.googleapis.com/fusiontables/v1'

default_cite_collection_editor_config =
  google_client_id: '891199912324.apps.googleusercontent.com'

  console.log "Query: #{query}"
  switch query.split(' ')[0]
    when 'INSERT'
      $.ajax "#{FUSION_TABLES_URI}/query",
        type: 'POST'
        dataType: 'json'
        crossDomain: true
        beforeSend: (xhr) ->
          xhr.setRequestHeader('Authorization',"Bearer #{get_cookie 'access_token'}")
        data:
          sql: query
        error: (jqXHR, textStatus, errorThrown) ->
