If you want to perform a sandbox login process for Salesforce, then you can use OAuth 2.0 authentication. The Salesforce provides a REST-based API for getting access tokens. You can use these tokens for the process of authentication so that you can gain access to the Salesforce sandbox.
Here is a simplified example given by Python programminglanguage using the ârequestâ library:-
Import requests
# Salesforce OAuth endpoint
Oauth_url = âhttps://login.salesforce.com/services/oauth2/tokenâ
# Replace with your Salesforce sandbox credentials
Client_id = âyour_client_idâ
Client_secret = âyour_client_secretâ
Username = âyour_usernameâ
Password = âyour_passwordâ
# Requesting access token
Data = {
  âgrant_typeâ: âpasswordâ,
  âclient_idâ: client_id,
  âclient_secretâ: client_secret,
  âusernameâ: username,
  âpasswordâ: password
}
Response = requests.post(oauth_url, data=data)
Access_token = response.json()[âaccess_tokenâ]
# Use the access token for subsequent Salesforce API requests
# For example, querying an object in the sandbox
Query_url = âhttps://your-sandbox-instance.salesforce.com/services/data/v54.0/query?q=SELECT+Id,Name+FROM+Accountâ
Headers = {âAuthorizationâ: fâBearer {access_token}â}
Query_response = requests.get(query_url, headers=headers)
Print(query_response.json())
You can replace âyour_client_idâ, âyour_client_secretâ, âyour_usernameâ, âyour_passwordâ and âyour_sandbox instanceâ with your real respective elements, credentials, and instance URLs.
The above script will help you authenticate to Salesforce. It will also help in obtaining an access token, and then after it use that token for making a query to the Salesforce API in the sandbox.