Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,12 +17,16 @@ app.config["SESSION_TYPE"] = "filesystem" # Use filesystem for session storage
|
|
| 17 |
Session(app) # Initialize the session interface
|
| 18 |
CORS(app) # Enable Cross-Origin Resource Sharing (CORS)
|
| 19 |
|
| 20 |
-
# Salesforce OAuth URLs and credentials
|
| 21 |
SALESFORCE_OAUTH_URL = "https://login.salesforce.com/services/oauth2/authorize"
|
| 22 |
SALESFORCE_TOKEN_URL = "https://login.salesforce.com/services/oauth2/token"
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# OAuth flow to redirect to Salesforce login
|
| 28 |
@app.route('/login')
|
|
@@ -58,7 +62,8 @@ def oauth_callback():
|
|
| 58 |
session['access_token'] = access_token
|
| 59 |
session['instance_url'] = instance_url
|
| 60 |
|
| 61 |
-
|
|
|
|
| 62 |
else:
|
| 63 |
return jsonify({"error": "Failed to authenticate with Salesforce"}), 400
|
| 64 |
|
|
@@ -88,7 +93,7 @@ def get_salesforce_connection():
|
|
| 88 |
sf = Salesforce(
|
| 89 |
username=os.getenv('SALESFORCE_USERNAME', 'your_username'),
|
| 90 |
password=os.getenv('SALESFORCE_PASSWORD', 'your_password'),
|
| 91 |
-
security_token=
|
| 92 |
)
|
| 93 |
return sf
|
| 94 |
|
|
|
|
| 17 |
Session(app) # Initialize the session interface
|
| 18 |
CORS(app) # Enable Cross-Origin Resource Sharing (CORS)
|
| 19 |
|
| 20 |
+
# Salesforce OAuth URLs and credentials (hardcoded as per your request)
|
| 21 |
SALESFORCE_OAUTH_URL = "https://login.salesforce.com/services/oauth2/authorize"
|
| 22 |
SALESFORCE_TOKEN_URL = "https://login.salesforce.com/services/oauth2/token"
|
| 23 |
+
|
| 24 |
+
# Hardcoded Salesforce credentials
|
| 25 |
+
CLIENT_ID = '3MVG9WVXk15qiz1JbtW1tT9a7WojFUbAfMVyVXfvI4PISHAKAxmZ8RLS1lBHqpnaDPQPZOOInuVdcQpi7smWc'
|
| 26 |
+
CLIENT_SECRET = '36C463CD713C420BA2ED78F853359EACCE1ECCE2954C9810FFD7F946564CB0E8'
|
| 27 |
+
SECURITY_TOKEN = 'sSSjyhInIsUohKpG8sHzty2q'
|
| 28 |
+
|
| 29 |
+
REDIRECT_URI = 'https://huggingface.co/spaces/Yaswanth56/python_test/oauth/callback' # Your redirect URI
|
| 30 |
|
| 31 |
# OAuth flow to redirect to Salesforce login
|
| 32 |
@app.route('/login')
|
|
|
|
| 62 |
session['access_token'] = access_token
|
| 63 |
session['instance_url'] = instance_url
|
| 64 |
|
| 65 |
+
# Redirect user to the dashboard or home page after successful login
|
| 66 |
+
return redirect('/dashboard')
|
| 67 |
else:
|
| 68 |
return jsonify({"error": "Failed to authenticate with Salesforce"}), 400
|
| 69 |
|
|
|
|
| 93 |
sf = Salesforce(
|
| 94 |
username=os.getenv('SALESFORCE_USERNAME', 'your_username'),
|
| 95 |
password=os.getenv('SALESFORCE_PASSWORD', 'your_password'),
|
| 96 |
+
security_token=SECURITY_TOKEN # Hardcoded Security Token
|
| 97 |
)
|
| 98 |
return sf
|
| 99 |
|