alexbegg commented on a change in pull request #19530:
URL: https://github.com/apache/airflow/pull/19530#discussion_r747057206
##########
File path: airflow/providers/salesforce/hooks/salesforce.py
##########
@@ -131,22 +131,39 @@ def get_conn(self) -> api.Salesforce:
if not self.conn:
connection = self.get_connection(self.conn_id)
extras = connection.extra_dejson
+ # all extras below (besides the version one) are explicitly
defaulted to None
+ # because simple-salesforce has a built-in authentication-choosing
method that
+ # relies on which arguments are None and without "or None" setting
this connection
+ # in the UI will result in the blank extras being empty strings
instead of None,
+ # which would break the connection if "get" was used on its own.
self.conn = Salesforce(
username=connection.login,
password=connection.password,
- security_token=extras["extra__salesforce__security_token"] or
None,
- domain=extras["extra__salesforce__domain"] or None,
+ security_token=extras.get('security_token')
Review comment:
In most cases when defining a connection using a secrets backend, such
as via an environment variable, or using a provider's secrets backend, it is
not typical to have to put the full "extra__salesforce__security_token" name.
Even the connections documentation for the Salesforce provider
(https://airflow.apache.org/docs/apache-airflow-providers-salesforce/stable/connections/salesforce.html)
shows defining the connection as an environment variable like so:
`export
AIRFLOW_CONN_SALESFORCE_DEFAULT='http://your_username:your_password@https%3A%2F%2Fyour_host.lightning.force.com?security_token=your_token'`
which is currently incorrect. Without this PR, you would need to provide it
like so (with all of the extras defined:
`export
AIRFLOW_CONN_SALESFORCE_DEFAULT='http://your_username:your_password@https%3A%2F%2Fyour_host.lightning.force.com?extra__salesforce__security_token=your_token&extra__salesforce__domain=&extra__salesforce__instance=&extra__salesforce__instance_url=&extra__salesforce__organization_id=&extra__salesforce__version=&extra__salesforce__proxies=&extra__salesforce__client_id=Aiflow&extra__salesforce__consumer_key=&extra__salesforce__private_key_file_path=&extra__salesforce__private_key='`
So, this PR is to allow for `?security_token=your_token` as shown in the
documentation, instead of having to do
`?extra__salesforce__security_token=your_token`
I can't find another provider that requires the `extra__`-prefixed name to
be used when defining the connection via environment variable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]