question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cross platform cookie file format

See original GitHub issue

Currently the cookie file is encoded with pythons pickle dump function, requiring a Python env. to generate.

If the library supported simple text file or other encoding, it would make the use of this great library more accessible to those less familiar with python. Much like wget/curl operate.

i.e.

wget -x --load-cookies cookies.txt "https://www.google.com/maps/@40.7484986,-73.9857129,15z?hl=en"
curl --cookie cookies.txt "https://www.google.com/maps/@40.7484986,-73.9857129,15z?hl=en"

This is particularly the case with apps like Home Assistant (hass.io), where python env. is not exposed to run the mapscookiegettercli

Where the library supported a plain text file, an extensions such as Export Cookies txt could be used.

Alternatively other scripting languages could leverage the Selenium Webdriver to extract cookies.

#Credits https://tech.mavericksevmont.com/blog/powershell-selenium-automate-web-browser-interactions-part-i/
#Credits https://github.com/costastf/mapscookiegettercli

$MAPS_LOGIN = 'https://accounts.google.com/signin/v2/identifier?'`
              +'hl=en&'`
              +'passive=true&'`
              +'continue=https%3A%2F%2Fwww.google.com%2Fmaps%2F%4040.7484986%2C-73.9857129%2C15z%3Fhl%3Den&'`
              +'service=local&'`
              +'flowName=GlifWebSignIn&'`
              +'flowEntry=ServiceLogin'

$LOGGED_IN_HEURISTIC = 'Find local businesses, view maps and get driving directions in Google Maps.'


$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
if($env:PATH -notlike "*$scriptPath*") { $env:PATH += ";$scriptPath\" }

Add-Type -Path "$scriptPath\WebDriver.dll"
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver # Creates an instance of this class to control Selenium and stores it in an easy to handle variable

$ChromeDriver.Navigate().GoToURL($MAPS_LOGIN)
while ($ChromeDriver.PageSource -notlike "*$LOGGED_IN_HEURISTIC*" )
{ 
    Sleep -Milliseconds 500
}
$ChromeDriver.Manage().Cookies.AllCookies.GetEnumerator()

#Code to store file in json/plaintext

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:39 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
costastfcommented, Sep 1, 2019

release 4.1.0 implements text based cookies. Thanks a lot for this great idea @macf0x and apologies for the long implementation time!

0reactions
costastfcommented, Feb 14, 2020

Hi Laurent, I am sorry to hear you are having so much trouble and also i am sorry for not responding more actively but it has been very very hectic. Frankly there is not much that can be done so i am answering just to give some history that might help you with troubleshooting or understanding.

This project has seen three evolution stages. The first on implemented google authentication directly by doing the authentication dance and submitting to the web url of the authentication mechanism of google to get a valid session. That worked quite well, but google has many many authentication mechanisms all over the world so depending on where you lived you might not be so lucky and also it did not support any other setting apart from a simple non MFA account.

The second iteration was with an external process that drove a browser via selenium which essentially could support any account setting since it was fully human interactive. The problem with that approach is that selenium is really easy to identify, and of course there are work arounds for that but that is a cat and mouse game that is not fun to play against google and I do not have the time, nor the inclination to do that.

So current iteration depends on a person using a proper browser and authenticating and extracting the cookies. You will notice that in all situations basically what happens is that we use the browser cookies so the way you get them makes no difference on the software and I would argue that the last method is actually the most robust since there is no automation in between to be flaged as fraudulent by google. That being said be certain that google invests a lot of effort to identify fraudulent traffic so I think that in your case what happens is that your network patterns flags your traffic as fraudulent and you get temporarily blocked. The same things happens to me for example, whenever my wife tries to access maps from her laptop in the house she gets a captcha prompts and I guess that my HA gets blocked for an hour which I do not mind.

So basically there is not much we can do about it, google is constantly tightening their fraud detection technics so if I had to guess on why it does not work now where it did before, I would say that it is probably because google advanced their fraud detection technics in your area and your network traffic gets flaged. I am sorry that I cannot provide any more that this as info. You can of course install an older version of the library and set it up on a box and see it that works longer for you and if that is the case then there might be something we could look into.

kind regards Costas

On Thu, Feb 13, 2020 at 8:12 AM lolomin notifications@github.com wrote:

Hi,

Tried for the second time with a 3 mins interval and cookie lasted for approximately 2 days each time but finally expired, again I can’t understand why when logging though the previous method with kogin/password was working for months… will now try with a 5 mins interval but with 3 mins interval it already clearly makes the detection less quicker for actions based on geolocation on a domotic system. If not working with 5 mins interval, will probably switch to solution like owntracks …

Regards.

Laurent

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/costastf/locationsharinglib/issues/66?email_source=notifications&email_token=ABDMK22ROUY27AH22UQOUHTRCTXHFA5CNFSM4IKTLZKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELTVEHI#issuecomment-585585181, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDMK2ZPI3SVNHT3IRQMO3DRCTXHFANCNFSM4IKTLZKA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using HTTP cookies - MDN Web Docs
For example, by following a link from an external site. None specifies that cookies are sent on both originating and cross-site requests, but ......
Read more >
Set cookies for cross origin requests - Stack Overflow
Cross site approach. To allow receiving & sending cookies by a CORS request successfully, do the following. Back-end (server) HTTP header settings:.
Read more >
HTTP cookie - Wikipedia
HTTP cookies are small blocks of data created by a web server while a user is browsing a website and placed on the...
Read more >
HTTP Cookies - curl
The cookie file format is text based and stores one cookie per line. Lines that start with # are treated as comments. Each...
Read more >
What Are Cookie Files and How to Test Them? - TestMatick
Cookie files can be considered as identification of the user in order to track his/her actions on the web portal pages. For example,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found