Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get GPS data from Waze with rest-client?

I'm trying to get my GPS data from the Waze app using the rest-client lib. I'm basicly trying to fake a login via the website https://www.waze.com/. After login (you can use JohnDoeSpeedy228:gre@tStory92) when you visit https://www.waze.com/editor/, click on "Drives" after review the the network calls you'll get to see the raw JSON data.

I seem to have succesfully logged in but when making the request to return the list of all my drives it returns the following

{"users"=>{"objects"=>[]}, "archives"=>{"totalSessions"=>0, "objects"=>[]}}

It should return something like this:

{
   "users":{
      "objects":[

      ]
   },
   "archives":{
      "totalSessions":1,
      "objects":[
         {
            "id":<REDACTED>,
            "userID":<REDACTED>,
            "existingRoadMeters":2839,
            "newRoadMeters":0,
            "totalRoadMeters":2839,
            "startTime":1456996197000,
            "endTime":1456996636000,
            "hasFullSession":true
         }
      ]
   }
}

Here's what I'm trying:

require 'rest-client'
require 'json'

GET_CSRF_URL = "https://www.waze.com/login/get"
SESSION_URL = "https://www.waze.com/login/create"
SESSION_LIST_URL = "https://www.waze.com/Descartes-live/app/Archive/List"
SESSON_DATA_URL = "https://www.waze.com/Descartes-live/app/Archive/Session"
AUTH = {'user_id'=>'JohnDoeSpeedy228','password'=>'gre@tStory92'}

req = RestClient.get(GET_CSRF_URL)
csrfhash = req.cookies
csrfhash['editor_env'] = 'row'
headers = {'X-CSRF-Token'=>csrfhash['_csrf_token']}

log = RestClient::Request.execute(
  method: :post,
  url: SESSION_URL,
  cookies: csrfhash,
  headers: headers,
  payload: AUTH
)

ses = RestClient::Request.execute(
  method: :get,
  url: SESSION_LIST_URL,
  cookies: log.cookies,
  payload: {'minDistance'=>1000,'count'=>50, 'offset'=>0}
)

puts JSON.parse(ses)

Am I doing something wrong?

like image 579
narzero Avatar asked Nov 08 '22 19:11

narzero


1 Answers

My guess is that you are confusing two accounts. Are you sure you logged a drive while logged in as JohnDoeSpeedy228? If there are no sessions from that user when logged into the site manually, I wouldn't expect the code to work either.

We can't find any of your drives.

Have you started driving with the Waze app yet? If so, please make sure you logged into the Map Editor with the same credentials you use in the app.

like image 150
Stephen Grimes Avatar answered Nov 15 '22 11:11

Stephen Grimes