subhamX / overleaf_sync_with_git

🤖 A GitHub action to take backups from OverLeaf which is an Online LaTeX Editor.
Apache License 2.0
22 stars 9 forks source link

curl error #3

Closed emhl closed 1 year ago

emhl commented 1 year ago

tonight the gh action i use to backup my projects broke. i first thought the cookie had timed out, but updating the cookie secret did nothing

i decided to manually execute the curl command from the entrypoint.sh and when i used the encoded cookie (or no cookie at all ) i got an html page with the text: Restricted, sorry you don’t have permission to load this page. image

when usind the decoded cookie i got the following traceback from curl (in verbose mode)

*   Trying 34.120.52.64:443...
* Connected to www.overleaf.com (34.120.52.64) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=overleaf.com
*  start date: Sep 27 19:24:03 2022 GMT
*  expire date: Dec 26 19:24:02 2022 GMT
*  subjectAltName: host "www.overleaf.com" matched cert's "www.overleaf.com"
*  issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1D4
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /project/XXXXX/download/zip]
* h2h3 [:scheme: https]
* h2h3 [:authority: www.overleaf.com]
* h2h3 [user-agent: curl/7.85.0]
* h2h3 [accept: */*]
* h2h3 [overleaf_session2=s:XXXX-XXXX-XXXX]
* Using Stream ID: 1 (easy handle 0x5576be4e1820)
> GET /project/XXXXX/download/zip HTTP/2
> Host: www.overleaf.com
> user-agent: curl/7.85.0
> accept: */*
> overleaf_session2=s:XXXX-XXXX-XXXX
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/2 400 
< content-type: text/html; charset=UTF-8
< referrer-policy: no-referrer
< content-length: 273
< date: Tue, 04 Oct 2022 11:58:00 GMT
< 
* HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
* Connection #0 to host www.overleaf.com left intact
curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

did overleaf change something, so different headers are required to download the project content?

subhamX commented 1 year ago

Thank you for sharing the error @emhl; Having a look at it right away..

subhamX commented 1 year ago

Hey @emhl;

If I try to visit https://www.overleaf.com/project/633c60f3c9a84d4d3996324f/download/zip (for example) in incognito (and not authenticated). I see the same error as you've shown.

image

But it works absolutely fine if I log in to my overleaf account, and then visit the URL.

I also ran the workflow, and everything seems to work fine.

image

So I would suggest the following two things:

  1. Please ensure that OVERLEAF_PROJECT_ID secret is updated.
  2. Ensure that OVERLEAF_COOKIE is in format cookie: overleaf_session2=<<value>>.

Let me know if you still face any errors.

emhl commented 1 year ago

i just took a look at it again, and the main problem was, that i forgot the Cookie: in front of the overleaf_session2= it would probably be easyer if we would only need to set the Cookie and not the rest of the string when the cookie expires

emhl commented 1 year ago

thanks for the fast response, i'll create a PR with the things i'd like to see changed :D