diff --git a/creds/google_converse_test_oauth.json b/creds/google_converse_test_oauth_20241122.json similarity index 100% rename from creds/google_converse_test_oauth.json rename to creds/google_converse_test_oauth_20241122.json diff --git a/creds/google_tcaoff_test_oauth_20241125.json b/creds/google_tcaoff_test_oauth_20241125.json new file mode 100644 index 0000000..4b846de --- /dev/null +++ b/creds/google_tcaoff_test_oauth_20241125.json @@ -0,0 +1 @@ +{"web":{"client_id":"494562005604-huknn3ll9t0firtpsasf9q45umehebvv.apps.googleusercontent.com","project_id":"gmail-integration-442808","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["https://thecaoffice.com/nexcom/converse/callback/gmail"]}} \ No newline at end of file diff --git a/run.sh b/run.sh index 3130dae..702cf79 100644 --- a/run.sh +++ b/run.sh @@ -2,7 +2,7 @@ # Use this to run the microservice without any docker setup. source .venv/bin/activate -python3 "$(pwd)/api/main.py" --host "127.0.0.1" --port 5106 --workers 4 --script-id "kps_cnv_KBC3MoaU" & +python3 "$(pwd)/api/main.py" --host "0.0.0.0" --port 5106 --workers 4 --script-id "kps_cnv_KBC3MoaU" & deactivate # All done: diff --git a/utils_v2/oauth/services/goog.py b/utils_v2/oauth/services/goog.py index d9024f1..1ddc2c2 100644 --- a/utils_v2/oauth/services/goog.py +++ b/utils_v2/oauth/services/goog.py @@ -306,12 +306,12 @@ if __name__ == "__main__": import dateparser - secrets_file = r"../../../creds/google_converse_test_oauth.json" + secrets_file = r"../../../creds/google_tcaoff_test_oauth_20241125.json" secrets_dict = json.from_file(secrets_file) my_goog = GoogleOAuth( config = secrets_dict, - redirect_url = r"https://nexcom.ditscentre.in/converse/test/callback", + redirect_url = r"https://thecaoffice.com/nexcom/converse/mail/callback/gmail", debug = True, debug_prefix = "OAuth (Goog) | " ) @@ -319,29 +319,29 @@ if __name__ == "__main__": async def main(): await my_goog.initialize(scopes = SCOPES_GMAIL_MAIL_MANAGEMENT) - # await asyncio.sleep(1.0) - # print("AUTH URL 0:", await my_goog.get_authorization_url( - # user_id = "BHOPLI", - # # email = "pskhushal@gmail.com" - # )) + await asyncio.sleep(1.0) + print("AUTH URL 0:", await my_goog.get_authorization_url( + user_id = "BHOPLI", + # email = "pskhushal@gmail.com" + )) + + redirect_url = input("Paste the redirect URL here: ") + print("TOKENS:", json.to_string(await my_goog.get_tokens(redirect_url = redirect_url), default = str)) + + # old_tok = { + # "access_token": "ya29.a0AeDClZAjmLUZ1hh0aTbddz4ThjRzwQNMwdi_H4AYO-C4ETvWpK8aHYz5eV9PTUlFDJKQoHYtFgu4u2XfoiOdIEMVNwAKFbb8sakIWef7Yk5HdiDYC0A-MUp5XZnoNGLuP_GW_O3IxfCLH7cC0fb3AfHx4OsBpa_Qu1X-IpvfaCgYKAaoSARMSFQHGX2MiX81qoRex393eWE229OMCUg0175", + # "refresh_token": "1//0g4mVQrydnc1ECgYIARAAGBASNgF-L9Irk_UxcRjgkz_YyK5Ujs1qCaj8nKL7bqQ0jHnHYlpVRh_Pwm77X4Angp8R-o-fgmKfzg", + # "expires_in": 3539, + # "expires_at": dateparser.parse("2024-11-25 09:24:56.690876+00:00"), + # "token_type": "Bearer", + # "scopes": [ + # "https://www.googleapis.com/auth/gmail.labels", + # "https://www.googleapis.com/auth/gmail.modify" + # ] + # } # - # redirect_url = input("Paste the redirect URL here: ") - # print("TOKENS:", json.to_string(await my_goog.get_tokens(redirect_url = redirect_url), default = str)) - - old_tok = { - "access_token": "ya29.a0AeDClZAjmLUZ1hh0aTbddz4ThjRzwQNMwdi_H4AYO-C4ETvWpK8aHYz5eV9PTUlFDJKQoHYtFgu4u2XfoiOdIEMVNwAKFbb8sakIWef7Yk5HdiDYC0A-MUp5XZnoNGLuP_GW_O3IxfCLH7cC0fb3AfHx4OsBpa_Qu1X-IpvfaCgYKAaoSARMSFQHGX2MiX81qoRex393eWE229OMCUg0175", - "refresh_token": "1//0g4mVQrydnc1ECgYIARAAGBASNgF-L9Irk_UxcRjgkz_YyK5Ujs1qCaj8nKL7bqQ0jHnHYlpVRh_Pwm77X4Angp8R-o-fgmKfzg", - "expires_in": 3539, - "expires_at": dateparser.parse("2024-11-25 09:24:56.690876+00:00"), - "token_type": "Bearer", - "scopes": [ - "https://www.googleapis.com/auth/gmail.labels", - "https://www.googleapis.com/auth/gmail.modify" - ] - } - - new_tok = await my_goog.refresh_tokens(old_tokens = old_tok) - print("NEW TOKENS:", json.to_string(new_tok, default = str)) + # new_tok = await my_goog.refresh_tokens(old_tokens = old_tok) + # print("NEW TOKENS:", json.to_string(new_tok, default = str)) asyncio.run(main())