nagasurendra commited on
Commit
4578d44
·
verified ·
1 Parent(s): 8dce271

Update utils/database_handler.py

Browse files
Files changed (1) hide show
  1. utils/database_handler.py +29 -14
utils/database_handler.py CHANGED
@@ -10,21 +10,36 @@ SECURITY_TOKEN = "GH9RG97LroDoLe6gAAOHaJBP"
10
 
11
  # Authenticate with Salesforce
12
  def get_salesforce_access_token():
 
13
  try:
14
- response = requests.post(
15
- SALESFORCE_URL,
16
- data={
17
- "grant_type": "password",
18
- "client_id": CLIENT_ID,
19
- "client_secret": CLIENT_SECRET,
20
- "username": USERNAME,
21
- "password": PASSWORD + SECURITY_TOKEN,
22
- },
23
- )
24
- response.raise_for_status()
25
- return response.json()["access_token"], response.json()["instance_url"]
26
- except Exception as e:
27
- print("Error obtaining Salesforce access token:", e)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  return None, None
29
 
30
  # Save user to Salesforce
 
10
 
11
  # Authenticate with Salesforce
12
  def get_salesforce_access_token():
13
+ """Authenticate with Salesforce Developer Org and get an access token."""
14
  try:
15
+ # Authentication URL for Salesforce production and Developer Org
16
+ auth_url = "https://login.salesforce.com/services/oauth2/token"
17
+
18
+ # Payload with credentials
19
+ payload = {
20
+ "grant_type": "password",
21
+ "client_id": "3MVG9PwZx9R6_UrcDlsRUsfM9CGTVKE82QnI5Vz02b.lv3H2yjDv_wy9.nrYihWYLUD1bv08N_qCG_gxiV5y8", # Consumer Key
22
+ "client_secret": "94983416FB1DF4E754B56F69982F07D94D8971523E6893B8A62D75CD8E9E3A34", # Consumer Secret
23
+ "username": "surendra@sathkrutha.ccom", # Developer Org username
24
+ "password": "Lavanyanaga@123" + "GH9RG97LroDoLe6gAAOHaJBP", # Password + Security Token
25
+ }
26
+
27
+ # Send POST request to authenticate
28
+ response = requests.post(auth_url, data=payload)
29
+
30
+ # Print full response for debugging
31
+ print("Response Status Code:", response.status_code)
32
+ print("Response Text:", response.text)
33
+
34
+ response.raise_for_status() # Raise error for bad HTTP responses
35
+
36
+ # Parse and return the access token and instance URL
37
+ access_token = response.json().get("access_token")
38
+ instance_url = response.json().get("instance_url")
39
+ print(f"Successfully authenticated. Instance URL: {instance_url}")
40
+ return access_token, instance_url
41
+ except requests.exceptions.RequestException as e:
42
+ print(f"Error obtaining Salesforce access token: {e}")
43
  return None, None
44
 
45
  # Save user to Salesforce