hlf20010508 / telegram-onedrive

A Telegram Bot to transfer files to OneDrive. No file size limitation. Restricted content supported. Doesn't occupy local space.
MIT License
49 stars 28 forks source link

Error on auth #11

Closed johnstones214 closed 11 months ago

johnstones214 commented 11 months ago

Can i run this from google cloud shell? I tried running it there it worked somewhat but I got stuck on the Telegram code verification. This was the error shown:

127.0.0.1 - - [17/Dec/2023 09:56:09] "POST /tg HTTP/1.1" 400 - telegram-onedrive | Error on request: telegram-onedrive | Traceback (most recent call last): telegram-onedrive | File "/usr/local/lib/python3.8/site-packages/werkzeug/serving.py", line 362, in run_wsgi telegram-onedrive | execute(self.server.app) telegram-onedrive | File "/usr/local/lib/python3.8/site-packages/werkzeug/serving.py", line 326, in execute telegram-onedrive | write(data) telegram-onedrive | File "/usr/local/lib/python3.8/site-packages/werkzeug/serving.py", line 292, in write telegram-onedrive | self.end_headers() telegram-onedrive | File "/usr/local/lib/python3.8/http/server.py", line 537, in end_headers telegram-onedrive | self.flush_headers() telegram-onedrive | File "/usr/local/lib/python3.8/http/server.py", line 541, in flush_headers telegram-onedrive | self.wfile.write(b"".join(self._headers_buffer)) telegram-onedrive | File "/usr/local/lib/python3.8/socketserver.py", line 826, in write telegram-onedrive | self._sock.sendall(b) telegram-onedrive | File "/usr/local/lib/python3.8/ssl.py", line 1204, in sendall telegram-onedrive | v = self.send(byte_view[count:]) telegram-onedrive | File "/usr/local/lib/python3.8/ssl.py", line 1173, in send telegram-onedrive | return self._sslobj.write(data) telegram-onedrive | ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:2485)

is there any fix for this? Also tried running it on my pc where i was able to login to my telegram account but when i got to onedrive auth , the browser shower authorized succesfully while bot says authorization failed. and gave the following error:

Traceback (most recent call last): File "/telegram-onedrive/modules/handlers/auth.py", line 134, in auth_handler onedrive.load_session() File "/telegram-onedrive/modules/onedrive.py", line 105, in load_session self.client.auth_provider.load_session(path=self.session_path) File "/usr/local/lib/python3.8/site-packages/onedrivesdk/auth_provider.py", line 323, in load_session self._session = self._session_type.load_session(**load_session_kwargs) File "/usr/local/lib/python3.8/site-packages/onedrivesdk/session.py", line 111, in load_session with open(path, "rb") as session_file: FileNotFoundError: [Errno 2] No such file or directory: 'session/onedrive.session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/telegram-onedrive/modules/handlers/auth.py", line 140, in auth_handler onedrive.auth(code) File "/telegram-onedrive/modules/onedrive.py", line 90, in auth self.client.auth_provider.authenticate( File "/usr/local/lib/python3.8/site-packages/onedrivesdk/auth_provider.py", line 206, in authenticate self._session = self._session_type(rcont["token_type"], KeyError: 'token_type'

Can you please help out in both these errors. thank you

hlf20010508 commented 11 months ago

I can’t help you with google cloud. For PC, I need to know

johnstones214 commented 11 months ago

1) image

2) https://[127.0.0.1](https://127.0.0.1:8000/auth?code=0.AW8AyM98hDqFv0KWDtKCPGExgiqObRbyVSZKmDhJ2a78xEXRAPk.AgABAAIAAAAmoFfGtYxvRrNriQdPKIZ-AgDs_wUA9P-ULWIXzG_toCsE1DWMpBJtv_0wonRJ9rN4uDK69gFaJbmwCufdzo64y_EagFRizVe86CBIO8uzop1VQb4MF1qPeh6Kddo9kKsZ2QMdWpYLZKbIq56VrZJ3uhFpKXXbyvEaYyDWqXFnFbqkyjHb0zdBBTiikP3SjHVUjTKEgG8ExfX3Z4d4UGdAbuzcop52Z_826lE6Y5t1Nb_ubuy5EO1is7L_H4HSn_0qfRyQ0vXoEO73xF73mEjWp0JlPXpjRdrTiBYWe7lQmBRDbB4bjUMiyOJg9seKA_HTSmpwMMzgor77ESlCt-ap7wlshWuM8JnXgC2C_10KcTGd2yjXBvdr9WpUdsNt5EyMqQVuQ-cOSHGzlUXFuHhi06BXK6DD58jLOyj0MAN4z-r4B4dOMgxRRJ63r98HUI_42P1i-0mxJT6qJba90g7d3Vcev4bWgfJtDZh_Dm-WND4rcBWTC9jaUBJypmJ33KOkAztLfHs3m7DRwkth54UAGlnIL93zKlrl3w0Ztgwnkw7iBhXQP9UyOO-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4dDwvlahA&session_state=0ad7982d-2e55-4908-9557-68d8ce0c9613#

3) Yes. image

4) Yes ,I retried. I got that same error as earlier. At my first try i was asked Telegram code which i got on app and it was authenticated. Then the onedrive link which took to me to a permissions page to which i agreed. and then it redirected to the link in 2) . when i checked bot i saw the error i originally posted and auth failed message in telegram app. Is it because of the 2 factor i have on microsoft account with microsoft authenticator ? Thanks

hlf20010508 commented 11 months ago

This is your auth response content {'error': 'invalid_client', 'error_description': "AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '166d8e2a-55f2-4a26-9838-49d9aefcc445'. Trace ID: 0df4db40-19f6-425d-9e73-311e670b0000 Correlation ID: d28e28c1-5032-4995-9799-701a1b78a78b Timestamp: 2023-12-17 11:42:53Z", 'error_codes': [7000215], 'timestamp': '2023-12-17 11:42:53Z', 'trace_id': '0df4db40-19f6-425d-9e73-311e670b0000', 'correlation_id': 'd28e28c1-5032-4995-9799-701a1b78a78b', 'error_uri': 'https://login.microsoftonline.com/error?code=7000215'}

It seems that your client secret is not correct. You need to record Value, not Secret ID, in Certificates & secrets step. Regenerate one and try again.

johnstones214 commented 11 months ago

it worked !! thanks alot

hlf20010508 commented 11 months ago

No problem.

johnstones214 commented 11 months ago

im sorry to concern you once again i got an error message when sending a video file which i hadnt downloaded but forwarded from a chat :

Error: Traceback (most recent call last): File "/telegram-onedrive/modules/handlers/transfer.py", line 31, in transfer_handler await multi_parts_uploader(tg_client, message.media.document, name, progress_callback=callback) AttributeError: 'NoneType' object has no attribute 'media'

hlf20010508 commented 11 months ago

Oh that's an old problem. I think this may be fixed if you're using the latest telegram. If this not works, the problem is the way of creating group. You need to follow these steps:

hlf20010508 commented 11 months ago

And make sure the bot is admin.

johnstones214 commented 11 months ago

I'm using the Telegram Desktop application from the original telegram website and not microsoft store. This is the version it is running: image

I can't find the update option in the settings too. I tried the other steps you told that didnt seem to work as well. Should I have stopped the docker container and tried those steps and then again docker-compose up ?

hlf20010508 commented 11 months ago

Try it on Telegram Web.

hlf20010508 commented 11 months ago

You can try to remove your container and recreate it. I've tried on telegram web, and it works fine.

hlf20010508 commented 11 months ago

I need to see your bot's rights. Like this:

image

An user had the same problem. He said he had to give it all rights, so that it could work.

johnstones214 commented 11 months ago

image

All the rights given already

hlf20010508 commented 11 months ago

He said he had to give the last two rights. Exactly the same situation as yours. It's very weird, but you have to.

johnstones214 commented 11 months ago

Thank you that did it. I have an additional question. Is it possible to run this on a VPS. Asking this because internet speed is less and it takes sometime to completely upload. Thank you very much for all your help !

hlf20010508 commented 11 months ago

Yes, you can. My bot is running on a VPS.

johnstones214 commented 11 months ago

May I know how you would use server_uri and the port settings there? Also uri for onedrive too

hlf20010508 commented 11 months ago

The same as localhost. If your VPS's host name is example.com, and if you want to use port 8000, make sure you opened port 8000 in your firewall, and use https://example.com:8000 as server_uri. On azure portal, use https://example.com:8000/auth as redirect uri.

hlf20010508 commented 11 months ago

If you have your own ssl certification, use them in docker-compose.yml. If you don't have host name, use ip address instead.

johnstones214 commented 11 months ago

I'm extremely new to this whole VPS , Docker and networking thing so i dont know how to get there.. is it okay if you can share your telegram id so i can message you personally. if u dont mind

hlf20010508 commented 11 months ago

No, I can't. You have to learn this knowledge on your own.

johnstones214 commented 11 months ago

alright thank you for your help