Hi! Where would I inject a string into the url for...
# contributing-to-airbyte
m
Hi! Where would I inject a string into the url for a Python API source using the Python CDK? In my case the user needs to provide both an authentication token and a numerical client id which needs to be a part of the API URL.
u
I have a working source connector but right now I have hard coded the cliend-id into the url_base
u
I did that through the combination of the
SourceName(AbstractSource)
function
streams
where I did something like this:
Copy code
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
        """
        :param config: A Mapping of the user input configuration as defined in the connector spec.
        """

        access_token = self._convert_auth_to_token(
            api_hostname=config["api_hostname"],
            client_id=config["client_id"],
            client_secret=config["client_secret"],
        )

        auth = TokenAuthenticator(
            token=access_token
        ) 

        args = {
            "base": config["api_hostname"],
        }

        return [
            Scorecards(authenticator=auth, **args)
        ]
Followed by a string concatenation in the stream class that inherits from the parent/base stream with:
Copy code
def path(self, **kwargs) -> str:
        return self.base + "employees"
Which results in a full URL of:
url_base
+
self.base
+
endpoint
Does that make sense?