Spaces:
Sleeping
Sleeping
Create get_token.py
Browse files- get_token.py +32 -0
get_token.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
# --- YOUR CREDENTIALS ---
|
| 4 |
+
code = "1000.c64b06a0dbcaedf4c8e4035239dde8ee.63f76dfac0c7475254cf1c39711366bd"
|
| 5 |
+
client_id = "1000.SIMKGAO5719K0TQ0QZQ31ZU57RLFNQ"
|
| 6 |
+
client_secret = "60b329b4fe51930abee900cba6524ec7332cd67e06"
|
| 7 |
+
redirect_uri = "http://www.google.com" # This must match what you entered in the console
|
| 8 |
+
|
| 9 |
+
# --- TRYING INDIAN DATA CENTER (.IN) FIRST ---
|
| 10 |
+
# Because your name/currency suggests India. If this fails, change .in to .com
|
| 11 |
+
url = "https://accounts.zoho.in/oauth/v2/token"
|
| 12 |
+
|
| 13 |
+
data = {
|
| 14 |
+
"code": code,
|
| 15 |
+
"client_id": client_id,
|
| 16 |
+
"client_secret": client_secret,
|
| 17 |
+
"redirect_uri": redirect_uri,
|
| 18 |
+
"grant_type": "authorization_code"
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
print(f"Connecting to {url}...")
|
| 22 |
+
response = requests.post(url, data=data)
|
| 23 |
+
|
| 24 |
+
print("\n--- ZOHO RESPONSE ---")
|
| 25 |
+
print(response.text)
|
| 26 |
+
|
| 27 |
+
if "refresh_token" in response.text:
|
| 28 |
+
print("\nSUCCESS! COPY THIS REFRESH TOKEN 👇")
|
| 29 |
+
print(response.json().get("refresh_token"))
|
| 30 |
+
else:
|
| 31 |
+
print("\nFAILED. If error is 'invalid_code', the 10 mins expired or Redirect URI mismatch.")
|
| 32 |
+
print("If error is 'invalid_client', try changing .in to .com in the URL.")
|