import requests from simple_salesforce import Salesforce # Salesforce credentials (Directly included in the code) consumer_key = '3MVG9PwZx9R6_UrfAEK05VEm.bbDjlyPoEYQnaiFNTcDfa05aATw.cuifiB.xlmJ3WkGveCyJErK5tsrgq_DM' consumer_secret = 'A4689ACC32DE07D94AD5511490C95FE63D98C30091170BA6ECF3286FF2AE44E0' username = 'venkatramana@sandbox.com' password = 'Seta12345@' security_token = 'Drl0jchCwLBfvX4ODMeFDksP' # Salesforce OAuth URL for production (use test.salesforce.com for sandbox) auth_url = 'https://login.salesforce.com/services/oauth2/token' # Prepare the data for OAuth token exchange data = { 'grant_type': 'password', 'client_id': consumer_key, 'client_secret': consumer_secret, 'username': username, 'password': f'{password}{security_token}' # Password and security token concatenated } # Make the POST request to exchange credentials for an access token response = requests.post(auth_url, data=data) # Check if authentication was successful if response.status_code == 200: # Extract the access token from the response access_token = response.json().get('access_token') instance_url = response.json().get('instance_url') # Use the access token to authenticate Salesforce sf = Salesforce(instance_url=instance_url, session_id=access_token) # Fetch Quote data from Salesforce (replace 'YOUR_QUOTE_ID' with actual Quote ID) quote_data = sf.query("SELECT Customer_Name__c, Quote_Date__c, Origination_Location__c, Total_Amount__c FROM Quote__c WHERE Id = 'YOUR_QUOTE_ID'") else: print(f"Error authenticating: {response.status_code}") print(response.text) # Return quote data def get_quote_data(): return quote_data